Skip to content

Commit

Permalink
Merge branch 'master' into copy_storage_files-fix-jonah
Browse files Browse the repository at this point in the history
  • Loading branch information
whitfiea authored Oct 23, 2024
2 parents dd6ef64 + 45730f3 commit e9ff89f
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 277 deletions.
4 changes: 3 additions & 1 deletion ibm/mas_devops/playbooks/br_health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mas_instance_id: "{{ lookup('env', 'MAS_INSTANCE_ID') }}"
mas_workspace_id: "{{ lookup('env', 'MAS_WORKSPACE_ID') }}"
db2_instance_id: "{{ lookup('env', 'DB2_INSTANCE_NAME') }}"
db2_namespace: "{{ lookup('env', 'DB2_NAMESPACE') }}"

# Define what action to perform
masbr_action: "{{ lookup('env', 'MASBR_ACTION') }}"
Expand Down Expand Up @@ -70,7 +71,8 @@
value: "{{ mas_workspace_id }}"
- name: "DB2_INSTANCE_NAME"
value: "{{ db2_instance_id }}"

- name: "DB2_NAMESPACE"
value: "{{ db2_namespace }}"

# Run backup/restore tasks locally
# -------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion ibm/mas_devops/playbooks/br_iot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mas_instance_id: "{{ lookup('env', 'MAS_INSTANCE_ID') }}"
mas_workspace_id: "{{ lookup('env', 'MAS_WORKSPACE_ID') }}"
db2_instance_id: "{{ lookup('env', 'DB2_INSTANCE_NAME') }}"
db2_namespace: "{{ lookup('env', 'DB2_NAMESPACE') }}"

# Define what action to perform
masbr_action: "{{ lookup('env', 'MASBR_ACTION') }}"
Expand Down Expand Up @@ -70,7 +71,8 @@
value: "{{ mas_workspace_id }}"
- name: "DB2_INSTANCE_NAME"
value: "{{ db2_instance_id }}"

- name: "DB2_NAMESPACE"
value: "{{ db2_namespace }}"

# Run backup/restore tasks locally
# -------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion ibm/mas_devops/playbooks/br_manage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mas_instance_id: "{{ lookup('env', 'MAS_INSTANCE_ID') }}"
mas_workspace_id: "{{ lookup('env', 'MAS_WORKSPACE_ID') }}"
db2_instance_id: "{{ lookup('env', 'DB2_INSTANCE_NAME') }}"
db2_namespace: "{{ lookup('env', 'DB2_NAMESPACE') }}"

# Define what action to perform
masbr_action: "{{ lookup('env', 'MASBR_ACTION') }}"
Expand Down Expand Up @@ -70,7 +71,8 @@
value: "{{ mas_workspace_id }}"
- name: "DB2_INSTANCE_NAME"
value: "{{ db2_instance_id }}"

- name: "DB2_NAMESPACE"
value: "{{ db2_namespace }}"

# Run backup/restore tasks locally
# -------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion ibm/mas_devops/playbooks/br_monitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mas_instance_id: "{{ lookup('env', 'MAS_INSTANCE_ID') }}"
mas_workspace_id: "{{ lookup('env', 'MAS_WORKSPACE_ID') }}"
db2_instance_id: "{{ lookup('env', 'DB2_INSTANCE_NAME') }}"
db2_namespace: "{{ lookup('env', 'DB2_NAMESPACE') }}"

# Define what action to perform
masbr_action: "{{ lookup('env', 'MASBR_ACTION') }}"
Expand Down Expand Up @@ -70,7 +71,8 @@
value: "{{ mas_workspace_id }}"
- name: "DB2_INSTANCE_NAME"
value: "{{ db2_instance_id }}"

- name: "DB2_NAMESPACE"
value: "{{ db2_namespace }}"

# Run backup/restore tasks locally
# -------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion ibm/mas_devops/playbooks/br_optimizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mas_instance_id: "{{ lookup('env', 'MAS_INSTANCE_ID') }}"
mas_workspace_id: "{{ lookup('env', 'MAS_WORKSPACE_ID') }}"
db2_instance_id: "{{ lookup('env', 'DB2_INSTANCE_NAME') }}"
db2_namespace: "{{ lookup('env', 'DB2_NAMESPACE') }}"

# Define what action to perform
masbr_action: "{{ lookup('env', 'MASBR_ACTION') }}"
Expand Down Expand Up @@ -70,7 +71,8 @@
value: "{{ mas_workspace_id }}"
- name: "DB2_INSTANCE_NAME"
value: "{{ db2_instance_id }}"

- name: "DB2_NAMESPACE"
value: "{{ db2_namespace }}"

# Run backup/restore tasks locally
# -------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions ibm/mas_devops/playbooks/mirror_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
when: mirror_mode != "from-filesystem"
vars:
case_name: ibm-mas
case_version: "{{ lookup('env', 'MAS_CORE_VERSION') | default (mas_core_version[mas_channel], True) }}"
case_version: "{{ lookup('env', 'MAS_CORE_VERSION') | default (mas_core_version[mas_channel], True) | replace('_', '.') }}"
exclude_images: []
ibmpak_skip_dependencies: true

- name: ibm.mas_devops.mirror_images
vars:
manifest_name: ibm-mas
manifest_version: "{{ lookup('env', 'MAS_CORE_VERSION') | default (mas_core_version[mas_channel], True) }}"
manifest_version: "{{ lookup('env', 'MAS_CORE_VERSION') | default (mas_core_version[mas_channel], True) | replace('_', '.') }}"
2 changes: 1 addition & 1 deletion ibm/mas_devops/roles/mirror_case_prepare/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ artifactory_image_repo: "{{ lookup('env', 'ARTIFACTORY_IMAGE_REPO') | default('d
# Case config
# -----------------------------------------------------------------------------
case_name: "{{ lookup('env', 'CASE_NAME') }}"
case_version: "{{ lookup('env', 'CASE_VERSION') }}"
case_version: "{{ lookup('env', 'CASE_VERSION') | replace('_', '.') }}"

# Overrides the settings for direct mirroring if defined
mirror_working_dir: "{{ lookup('env', 'MIRROR_WORKING_DIR') }}"
Expand Down
175 changes: 168 additions & 7 deletions ibm/mas_devops/roles/mirror_case_prepare/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,174 @@
- registry_public_url is defined and registry_public_url != ":"
fail_msg: "One or more required properties are missing"

# 2. Determine if dev or released Builds
# 2. Check for required software
# -----------------------------------------------------------------------------
- name: "{{ case_name }} : Prepare for dev/pre-release build versions"
when: '"-pre." is in case_version'
include_tasks: "tasks/prepare-dev.yml"
- name: "{{ case_name }} : Test if ibm-pak is installed"
shell: oc ibm-pak --version
register: ibmpak_version_result
ignore_errors: true

- name: "{{ case_name }} : Prepare for release build versions"
- name: "{{ case_name }} : Fail if ibm-pak is not installed"
assert:
that: ( ibmpak_version_result['rc'] == 0 )
fail_msg: "ibm-pak tool must be installed."

# 3. Debug
# -----------------------------------------------------------------------------

- name: "{{ case_name }} : Configure ibm-pak options"
set_fact:
ibmpak_flag_insecure: "{{ ibmpak_insecure | ternary('--insecure', '') }}"
ibmpak_flag_skip_verify: "{{ ibmpak_skip_verify | ternary('--skip-verify', '') }}"
ibmpak_flag_skip_dependencies: "{{ ibmpak_skip_dependencies | ternary('--skip-dependencies', '') }}"

- name: "{{ case_name }} : Airgap setup configuration"
debug:
msg:
- "Case Name .............................. {{ case_name }}"
- "Case Version ........................... {{ case_version }}"
- "Registry Public Host ................... {{ registry_public_host }}"
- "Registry Public Port ................... {{ registry_public_port }}"
- "Registry Prefix ........................ {{ registry_prefix}}"
- "Insecure ............................... {{ ibmpak_insecure }}"
- "Skip Verify ............................ {{ ibmpak_skip_verify }}"
- "Skip Dependencies ...................... {{ ibmpak_skip_dependencies }}"
- "IBM Pak Flags .......................... {{ ibmpak_flag_insecure }} {{ ibmpak_flag_skip_verify }} {{ ibmpak_flag_skip_dependencies }}"

# 4. Get the CASE bundle
# -----------------------------------------------------------------------------
- name: "{{ case_name }} : Get the CASE bundle"
shell: oc ibm-pak get {{ case_name }} --version {{ case_version }} {{ ibmpak_flag_insecure }} {{ ibmpak_flag_skip_verify }} {{ ibmpak_flag_skip_dependencies }}
register: ibmpak_get_result

# Team messed up the release and the version we will get back is 8.7.0+20230925.114420 rather than 8.7.0
- name: "Workaround for ibm-mas-manage 8.7.0"
when:
- case_name == "ibm-mas-manage"
- case_version == "8.7.0"
set_fact:
case_version: "8.7.0+20230925.114420"

# 5. Remove excluded images
# -----------------------------------------------------------------------------
# Some CASE bundles define images that we don't want to mirror, so delete the excluded image files.
- name: Delete excluded images
when:
- exclude_images is defined
- exclude_images | length > 0
shell: rm ~/.ibm-pak/data/cases/{{ case_name }}/{{ case_version }}/{{ item }}-*-images.csv
# We ignore errors, because if we can't delete something that isn't there it
# doesn't really matter, e.g. removing ibm-mas-safety which isn't present since MAS v8.8
ignore_errors: true
register: excludeImagesResult
loop: "{{ exclude_images }}"

# 6. Generate mirror-manifest
# -----------------------------------------------------------------------------
- name: Generate mirror-manifest with image group filter
block:
- name: "{{ case_name }} : Generate the mirror manifest from the CASE bundle (direct)"
shell: "oc ibm-pak generate mirror-manifests {{ case_name }} {{ registry_public_url }} --version {{ case_version }} --filter {{ image_group_filter }}"
register: ibmpak_gen1_result

- name: "{{ case_name }} : Generate the mirror manifest from the CASE bundle (indirect)"
shell: "oc ibm-pak generate mirror-manifests {{ case_name }} file:// --version {{ case_version }} --final-registry {{ registry_public_url }} --filter {{ image_group_filter }}"
register: ibmpak_gen2_result
when: image_group_filter is defined

- name: Generate mirror-manifest without image group filter
block:
- name: "{{ case_name }} : Generate the mirror manifest from the CASE bundle (direct)"
shell: "oc ibm-pak generate mirror-manifests {{ case_name }} {{ registry_public_url }} --version {{ case_version }}"
register: ibmpak_gen1_result

- name: "{{ case_name }} : Generate the mirror manifest from the CASE bundle (indirect)"
shell: "oc ibm-pak generate mirror-manifests {{ case_name }} file:// --version {{ case_version }} --final-registry {{ registry_public_url }}"
register: ibmpak_gen2_result
when: image_group_filter is not defined

# 7. Collect generated files
# -----------------------------------------------------------------------------
- name: "{{ case_name }} : Create target directories (direct)"
file:
path: "{{ mirror_working_dir }}/manifests/direct"
state: directory

- name: "{{ case_name }} : Create target directories (to)"
file:
path: "{{ mirror_working_dir }}/manifests/to-filesystem"
state: directory

- name: "{{ case_name }} : Create target directories (from)"
file:
path: "{{ mirror_working_dir }}/manifests/from-filesystem"
state: directory

# 8. Save the manifests to our working directory
# -----------------------------------------------------------------------------
# Team messed up the release and the version we will get back is 8.7.0+20230925.114420 rather than 8.7.0
#
# Note: We use _manifest_version to avoid conflict with manifest_version that is used as an input to
# the mirror_images role. If we set a manifest_version fact it will override the value passed into all
# mirror_image roles invoked in a playbook.
- name: "Set manifest version"
set_fact:
_manifest_version: "{{ case_version }}"

- name: "Workaround for ibm-mas-manage 8.7.0"
when:
- '"-pre." is not in case_version'
include_tasks: "tasks/prepare-released.yml"
- case_name == "ibm-mas-manage"
- case_version == "8.7.0+20230925.114420"
set_fact:
_manifest_version: "8.7.0"

- name: "{{ case_name }} : Copy images-mapping-to-filesystem"
ansible.builtin.copy:
src: ~/.ibm-pak/data/mirror/{{ case_name }}/{{ case_version }}/images-mapping-to-filesystem.txt
dest: "{{ mirror_working_dir }}/manifests/to-filesystem/{{ case_name }}_{{ _manifest_version }}.txt"

- name: "{{ case_name }} : Copy images-mapping-from-filesystem"
ansible.builtin.copy:
src: ~/.ibm-pak/data/mirror/{{ case_name }}/{{ case_version }}/images-mapping-from-filesystem.txt
dest: "{{ mirror_working_dir }}/manifests/from-filesystem/{{ case_name }}_{{ _manifest_version }}.txt"

- name: "{{ case_name }} : Copy images-mapping"
ansible.builtin.copy:
src: ~/.ibm-pak/data/mirror/{{ case_name }}/{{ case_version }}/images-mapping.txt
dest: "{{ mirror_working_dir }}/manifests/direct/{{ case_name }}_{{ _manifest_version }}.txt"

# 9. IBM SLS 3.5.0 Bad Digest Hack
# -----------------------------------------------------------------------------
# The SLS CASE bundle for 3.5.0 has the wrong image digest in it ... not really sure why TBH
- name: "IBM SLS 3.5.0 workaround"
when: case_name == "ibm-sls" and case_version == "3.5.0"
include_tasks: "tasks/sls-350-fix.yml"

# 10. IBM UDS Entitled Image Hacks
# -----------------------------------------------------------------------------
# The UDS CASE bundle includes one entitled image - cp/uds/uds-submodule:2.0.8
- name: "IBM UDS 2.0.8 workaround"
when: case_name == "ibm-uds" and case_version == "2.0.8"
include_tasks: "tasks/uds-208-fix.yml"

# The UDS CASE bundle includes one entitled image - cp/uds/uds-submodule:2.0.9
- name: "IBM UDS 2.0.9 workaround"
when: case_name == "ibm-uds" and case_version == "2.0.9"
include_tasks: "tasks/uds-209-fix.yml"

# The UDS CASE bundle includes one entitled image - cp/uds/uds-submodule:2.0.10
- name: "IBM UDS 2.0.10 workaround"
when: case_name == "ibm-uds" and case_version == "2.0.10"
include_tasks: "tasks/uds-2010-fix.yml"

# 11. IBM Maximo IoT Hacks
# -----------------------------------------------------------------------------
# The IoT CASE bundle for 8.6.0 has an incorrect image digest in it
- name: "IBM IoT 8.6.0 workaround"
when: case_name == "ibm-mas-iot" and case_version == "8.6.0"
include_tasks: "tasks/iot-860-fix.yml"

# The IoT CASE bundle for 8.6.7 has an incorrect image digest in it
- name: "IBM IoT 8.6.7 workaround"
when: case_name == "ibm-mas-iot" and case_version == "8.6.7"
include_tasks: "tasks/iot-867-fix.yml"
87 changes: 0 additions & 87 deletions ibm/mas_devops/roles/mirror_case_prepare/tasks/prepare-dev.yml

This file was deleted.

Loading

0 comments on commit e9ff89f

Please sign in to comment.