Skip to content

Commit

Permalink
[minor] Add support mongo 5.0.23 and 6.0.12 (#1144)
Browse files Browse the repository at this point in the history
Co-authored-by: Sanjay Prabhakar <sanjay.prabhakar@uk.ibm.com>
  • Loading branch information
sanjayprab and Sanjay Prabhakar authored Dec 20, 2023
1 parent 017a0ad commit 0d13647
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 80 deletions.
26 changes: 26 additions & 0 deletions ibm/mas_devops/roles/mirror_extras_prepare/vars/mongoce_5.0.23.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
extra_images:
- name: mongodb/mongodb-kubernetes-operator
registry: quay.io
tag: 0.8.3
digest: sha256:9ef7a689b7f2789b436458a6d5f361ffcb4e182daa6c33d79687e87f268c7761 # 0.8.3-b20231215T000000Z

- name: mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook
registry: quay.io
tag: 1.0.8
digest: sha256:641ecd0798cd5b49a060df50ad60dc75d964430d6cf9b3d3e91ebc9b19a67a34 # 1.0.8-b20231215T000000Z

- name: mongodb/mongodb-agent
registry: quay.io
tag: 12.0.25.7724-1
digest: sha256:ae9a33c87fc623985b26140ed93bb2ea510fd3682279ea50770f9c4d47b20b2c # 12.0.25.7724-1

- name: mongodb/mongodb-kubernetes-readinessprobe
registry: quay.io
tag: 1.0.17
digest: sha256:99013fbeb1dccde1f4995adba188b95ce14b336d587730146d3695cb175fcf03 # 1.0.17-b20231215T000000Z

- name: ibmmas/mongo
registry: quay.io
tag: 5.0.23
digest: sha256:2d91d0b38b28660e068a77fea8bc51cfdd97e2b8c236c5eeaacdfa50fa798231 # quay.io/mongodb/mongodb-community-server:5.0.23-ubi8-20231214T080737Z
26 changes: 26 additions & 0 deletions ibm/mas_devops/roles/mirror_extras_prepare/vars/mongoce_6.0.12.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
extra_images:
- name: mongodb/mongodb-kubernetes-operator
registry: quay.io
tag: 0.8.3
digest: sha256:9ef7a689b7f2789b436458a6d5f361ffcb4e182daa6c33d79687e87f268c7761 # 0.8.3-b20231215T000000Z

- name: mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook
registry: quay.io
tag: 1.0.8
digest: sha256:641ecd0798cd5b49a060df50ad60dc75d964430d6cf9b3d3e91ebc9b19a67a34 # 1.0.8-b20231215T000000Z

- name: mongodb/mongodb-agent
registry: quay.io
tag: 12.0.25.7724-1
digest: sha256:ae9a33c87fc623985b26140ed93bb2ea510fd3682279ea50770f9c4d47b20b2c # 12.0.25.7724-1

- name: mongodb/mongodb-kubernetes-readinessprobe
registry: quay.io
tag: 1.0.17
digest: sha256:99013fbeb1dccde1f4995adba188b95ce14b336d587730146d3695cb175fcf03 # 1.0.17-b20231215T000000Z

- name: ibmmas/mongo
registry: quay.io
tag: 6.0.12
digest: sha256:64ed5175850c3be8bd2976823e245141c4e6a7046102136f8c333850dbe6a399 # quay.io/mongodb/mongodb-community-server:6.0.12-ubi8-20231214T084821Z
2 changes: 1 addition & 1 deletion ibm/mas_devops/roles/mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The namespace where the operator and MongoDb cluster will be deployed.
- Default Value: `mongoce`

### mongodb_version
Defines the specific mongo version to be used. Best practice would be to use the version associated with the current Maximo Application Suite catalog. However, this value can currently be overridden to 4.4.21, 5.0.21 or 6.0.10.
Defines the specific mongo version to be used. Best practice would be to use the version associated with the current Maximo Application Suite catalog. However, this value can currently be overridden to 4.4.21, 5.0.21, 5.0.23, 6.0.10 or 6.0.12

!!! important
It is advised to never attempt a downgrade a MongoDB instance managed by the MAS Devops Ansible Collection. Also best practices should include creating scheduled backups of any MongoDB instance.
Expand Down
3 changes: 2 additions & 1 deletion ibm/mas_devops/roles/mongodb/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ custom_labels: "{{ lookup('env', 'CUSTOM_LABELS') | default(None, true) | string
mongodb_v5_upgrade: "{{ lookup('env', 'MONGODB_V5_UPGRADE') | default(false, true) | bool }}"
mongodb_v6_upgrade: "{{ lookup('env', 'MONGODB_V6_UPGRADE') | default(false, true) | bool }}"

mongo_feature_compatibility_matrix:
mongo_compatibility_matrix_default:
"4.2": "4.4.21"
"4.4": "5.0.21"
"5.0": "6.0.10"
"6.0": "6.0.10"
105 changes: 105 additions & 0 deletions ibm/mas_devops/roles/mongodb/tasks/determine-ibmcatalog-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
# The MongoDB version is based on the chosen ibm-operator-catalog. However the
# ibm-operator-catalog does not explicitly include information about the mongo version.
#
# The configuration files in common_vars/casebundles do specify the MongoDB
# version for each of the MAS published ibm-operator-catalog catalogs.
#
# To determine which common_vars/casebundles configuration file to use, this role
# extracts the catalog_tag from the ibm-operator-catalog's displayName.
#
# For example:
# displayName: IBM Maximo Operators (v8-230926-amd64)
#
# catalog_tag is v8-230926-amd64
# MongoDB version will be determined by loading common_vars/casebundles/v8-230926-amd64.yml
#
# And FINALLY...
# If the MongoDB version cannot be determined from the above logic,
# the MongoDB version will be determined by the last configuration file in
# common_vars/casebundles/
#
# And if still it cannot be determined because perhaps its not specified in the
# configuration file, a default value will be used.

# List the common_vars/casebundle configuration files if last_catalog_tag is not defined
- block:
- name: "List yml files in common_vars/casebundles folder"
find:
paths: "{{ role_path }}/../../common_vars/casebundles"
patterns: "*.yml"
file_type: "file"
register: find_result

- debug:
var: find_result

# Determine the last configuration file in the list just in case we need it later
- set_fact:
last_catalog_tag: "{{ find_result['files'] | map(attribute='path') | map('regex_replace', '^.*/(.*).yml$', '\\1') | sort |last }}"
when: find_result is defined
when: last_catalog_tag is not defined or last_catalog_tag == ""

# Display the Last Catalog Version
- name: "Display the Last Catalog Version"
debug:
msg:
- "Last Catalog Version ............................ {{ last_catalog_tag }}"

# 1. Get the IBM Catalog if available
# -----------------------------------------------------------------------------
- name: "Lookup ibm-operator-catalog"
kubernetes.core.k8s_info:
api_version: operators.coreos.com/v1alpha1
name: ibm-operator-catalog
namespace: openshift-marketplace
kind: CatalogSource
register: catalog_lookup

- name: "Determine catalog version from catalog displayName"
block:
# extract the catalog tag from displayName
- set_fact:
catalog_tag: "{{ catalog_lookup.resources[0].spec.displayName.split('(')[1].split(')')[0].split(' ')[0] }}"
when:
- catalog_lookup is defined
- catalog_lookup.resources is defined
- catalog_lookup.resources | length > 0
- catalog_lookup.resources[0].spec is defined
- catalog_lookup.resources[0].spec.displayName is defined
- '"(" in catalog_lookup.resources[0].spec.displayName'

- name: Check if file exists in casebundles
stat:
path: "{{ role_path }}/../../common_vars/casebundles/{{ catalog_tag }}.yml"
register: file_exists_result
when: catalog_tag is defined and catalog_tag != ""

# use last_catalog_tag if the casebundles file does not exist
- set_fact:
catalog_tag: "{{ last_catalog_tag }}"
when:
- file_exists_result is defined
- file_exists_result.stat is defined
- file_exists_result.stat.exists is defined
- not file_exists_result.stat.exists
- last_catalog_tag is defined and last_catalog_tag != ""

# use last_catalog_tag if unable to get catalog_tag from displayName
- set_fact:
catalog_tag: "{{ last_catalog_tag }}"
when:
- catalog_tag is not defined
- last_catalog_tag is defined and last_catalog_tag != ""

rescue:
# use the last_catalog_tag when the catalog_tag cannot be determined from the displayName
- set_fact:
catalog_tag: "{{ last_catalog_tag }}"
when: last_catalog_tag is defined and last_catalog_tag != ""

- name: "Catalog Version"
debug:
msg:
- "Catalog Version ............................ {{ catalog_tag }}"
when: catalog_tag is defined and catalog_tag != ""
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,30 @@
set_fact:
existing_mongo_minor_version: "{{ existing_mongo_version | regex_search('(?<=)(.*)(?=...)') }}"

- include_tasks: tasks/determine-ibmcatalog-tag.yml

- name: Check if file exists in casebundles
stat:
path: "{{ role_path }}/../../common_vars/casebundles/{{ catalog_tag }}.yml"
register: stat_result
when: catalog_tag is defined and catalog_tag != ""

- name: Load CASE bundle versions
include_vars:
file: "{{ role_path }}/../../common_vars/casebundles/{{ catalog_tag }}.yml"
when: stat_result is defined and stat_result.stat.exists

# holds the expected target mongo version that is feature compatible with the existing mongo instance version
# mongo extras version are picked up from the catalog if available or uses defaults.
- name: Set mongo_compatible_target_version
set_fact:
mongo_compatible_target_version: "{{ mongo_feature_compatibility_matrix[existing_mongo_minor_version] }}"
vars:
mongo_feature_compatibility_matrix:
"4.2": "{{ mongo_extras_version_4 | default(mongo_compatibility_matrix_default['4.2'], true) }}"
"4.4": "{{ mongo_extras_version_5 | default(mongo_compatibility_matrix_default['4.4'], true) }}"
"5.0": "{{ mongo_extras_version_6 | default(mongo_compatibility_matrix_default['5.0'], true) }}"
"6.0": "{{ mongo_extras_version_6 | default(mongo_compatibility_matrix_default['6.0'], true) }}"

when:
- existing_mongodb.resources[0].spec.version is defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,87 +22,10 @@
# And if still it cannot be determined because perhaps its not specified in the
# configuration file, a default value will be used.

# List the common_vars/casebundle configuration files if last_catalog_tag is not defined
- block:
- name: "List yml files in common_vars/casebundles folder"
find:
paths: "{{ role_path }}/../../common_vars/casebundles"
patterns: "*.yml"
file_type: "file"
register: find_result

- debug:
var: find_result

# Determine the last configuration file in the list just in case we need it later
- set_fact:
last_catalog_tag: "{{ find_result['files'] | map(attribute='path') | map('regex_replace', '^.*/(.*).yml$', '\\1') | sort |last }}"
when: find_result is defined
when: last_catalog_tag is not defined or last_catalog_tag == ""

# Display the Last Catalog Version
- name: "Display the Last Catalog Version"
debug:
msg:
- "Last Catalog Version ............................ {{ last_catalog_tag }}"

# 1. Get the IBM Catalog if available
# -----------------------------------------------------------------------------
- name: "Lookup ibm-operator-catalog"
kubernetes.core.k8s_info:
api_version: operators.coreos.com/v1alpha1
name: ibm-operator-catalog
namespace: openshift-marketplace
kind: CatalogSource
register: catalog_lookup

- name: "Determine catalog version from catalog displayName"
block:
# extract the catalog tag from displayName
- set_fact:
catalog_tag: "{{ catalog_lookup.resources[0].spec.displayName.split('(')[1].split(')')[0].split(' ')[0] }}"
when:
- catalog_lookup is defined
- catalog_lookup.resources is defined
- catalog_lookup.resources | length > 0
- catalog_lookup.resources[0].spec is defined
- catalog_lookup.resources[0].spec.displayName is defined
- '"(" in catalog_lookup.resources[0].spec.displayName'

- name: Check if file exists in casebundles
stat:
path: "{{ role_path }}/../../common_vars/casebundles/{{ catalog_tag }}.yml"
register: file_exists_result
when: catalog_tag is defined and catalog_tag != ""

# use last_catalog_tag if the casebundles file does not exist
- set_fact:
catalog_tag: "{{ last_catalog_tag }}"
when:
- file_exists_result is defined
- file_exists_result.stat is defined
- file_exists_result.stat.exists is defined
- not file_exists_result.stat.exists
- last_catalog_tag is defined and last_catalog_tag != ""

# use last_catalog_tag if unable to get catalog_tag from displayName
- set_fact:
catalog_tag: "{{ last_catalog_tag }}"
when:
- catalog_tag is not defined
- last_catalog_tag is defined and last_catalog_tag != ""

rescue:
# use the last_catalog_tag when the catalog_tag cannot be determined from the displayName
- set_fact:
catalog_tag: "{{ last_catalog_tag }}"
when: last_catalog_tag is defined and last_catalog_tag != ""

- name: "Catalog Version"
debug:
msg:
- "Catalog Version ............................ {{ catalog_tag }}"
when: catalog_tag is defined and catalog_tag != ""
- include_tasks: tasks/determine-ibmcatalog-tag.yml

# 2. Load default settings
# -----------------------------------------------------------------------------
Expand Down

0 comments on commit 0d13647

Please sign in to comment.