|
| 1 | +--- |
| 2 | +- name: "Run ci/playbooks/edpm_baremetal_deployment_minor_update/run.yml" |
| 3 | + hosts: "{{ cifmw_zuul_target_host | default('all') }}" |
| 4 | + gather_facts: true |
| 5 | + tasks: |
| 6 | + - name: Filter out host if needed |
| 7 | + when: |
| 8 | + - cifmw_zuul_target_host is defined |
| 9 | + - cifmw_zuul_target_host != 'all' |
| 10 | + - inventory_hostname != cifmw_zuul_target_host |
| 11 | + ansible.builtin.meta: end_host |
| 12 | + |
| 13 | + - name: Check for edpm-ansible.yml file |
| 14 | + ansible.builtin.stat: |
| 15 | + path: "{{ ansible_user_dir }}/ci-framework-data/artifacts/edpm-ansible.yml" |
| 16 | + register: edpm_file |
| 17 | + |
| 18 | + - name: Check if new ssh keypair exists |
| 19 | + ansible.builtin.include_role: |
| 20 | + name: recognize_ssh_keypair |
| 21 | + |
| 22 | + - name: Add crc node in local inventory |
| 23 | + ansible.builtin.add_host: |
| 24 | + name: crc |
| 25 | + ansible_ssh_private_key_file: "{{ ansible_user_dir }}/.crc/machines/crc/{{ crc_ssh_keypair }}" |
| 26 | + ansible_ssh_user: core |
| 27 | + ansible_host: api.crc.testing |
| 28 | + |
| 29 | + - name: Ensure we know ssh hosts |
| 30 | + ansible.builtin.shell: |
| 31 | + cmd: "ssh-keyscan {{ hostvars[item].ansible_host }} >> ~/.ssh/known_hosts" |
| 32 | + loop: "{{ hostvars.keys() | reject('equalto', 'localhost') }}" |
| 33 | + |
| 34 | + - name: Inject CRC in zuul_inventory |
| 35 | + block: |
| 36 | + - name: Load zuul_inventory |
| 37 | + register: _inventory |
| 38 | + ansible.builtin.slurp: |
| 39 | + path: "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml" |
| 40 | + |
| 41 | + - name: Inject CRC in zuul_inventory.yml |
| 42 | + vars: |
| 43 | + _crc: |
| 44 | + all: |
| 45 | + hosts: |
| 46 | + crc: "{{ dict(hostvars.crc) }}" |
| 47 | + _updated: >- |
| 48 | + {{ |
| 49 | + _inventory.content | b64decode | from_yaml | combine(_crc, recursive=true) |
| 50 | + }} |
| 51 | + ansible.builtin.copy: |
| 52 | + dest: "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml" |
| 53 | + content: "{{ _updated | to_nice_yaml }}" |
| 54 | + mode: "0644" |
| 55 | + |
| 56 | + - name: Set default pre-update tag if not provided |
| 57 | + ansible.builtin.set_fact: |
| 58 | + cifmw_minor_update_pre_update_tag: "{{ cifmw_minor_update_pre_update_tag | default('18.0-fr4-latest') }}" |
| 59 | + |
| 60 | + - name: Get pre-update index image digest from tag |
| 61 | + ansible.builtin.shell: >- |
| 62 | + skopeo inspect |
| 63 | + docker://quay.io/openstack-k8s-operators/openstack-operator-index:{{ cifmw_minor_update_pre_update_tag }} |
| 64 | + | jq -r '.Digest' |
| 65 | + register: fr4_digest_result |
| 66 | + changed_when: false |
| 67 | + failed_when: fr4_digest_result.rc != 0 |
| 68 | + |
| 69 | + - name: Set FR4 index image using digest from tag |
| 70 | + ansible.builtin.set_fact: |
| 71 | + cifmw_minor_update_fr4_index_image: >- |
| 72 | + quay.io/openstack-k8s-operators/openstack-operator-index@{{ fr4_digest_result.stdout | trim }} |
| 73 | +
|
| 74 | + - name: Get PR index image from content provider or use default |
| 75 | + ansible.builtin.set_fact: |
| 76 | + cifmw_minor_update_pr_index_image: >- |
| 77 | + {{ |
| 78 | + cifmw_operator_build_output.operators['openstack-operator'].image_catalog |
| 79 | + if (cifmw_operator_build_output is defined and |
| 80 | + cifmw_operator_build_output.operators is defined and |
| 81 | + 'openstack-operator' in cifmw_operator_build_output.operators) |
| 82 | + else cifmw_minor_update_fr4_index_image |
| 83 | + }} |
| 84 | +
|
| 85 | + - name: Override operator build output with FR4 index image for Phase 1 |
| 86 | + ansible.builtin.set_fact: |
| 87 | + cifmw_operator_build_output_fr4: >- |
| 88 | + {{ |
| 89 | + { |
| 90 | + 'operators': { |
| 91 | + 'openstack-operator': { |
| 92 | + 'image_catalog': cifmw_minor_update_fr4_index_image |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + }} |
| 97 | +
|
| 98 | + - name: Phase 1 - Deploy with FR4 index image using deploy-edpm.yml |
| 99 | + block: |
| 100 | + - name: Write FR4 operator build output to temporary file |
| 101 | + ansible.builtin.copy: |
| 102 | + dest: "{{ ansible_user_dir }}/ci-framework-data/artifacts/operator_build_output_fr4.yml" |
| 103 | + content: "{{ cifmw_operator_build_output_fr4 | to_nice_yaml }}" |
| 104 | + mode: "0644" |
| 105 | + |
| 106 | + - name: Perform Podified and EDPM deployment on compute nodes with virtual baremetal (FR4) |
| 107 | + ansible.builtin.command: |
| 108 | + chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework" |
| 109 | + cmd: >- |
| 110 | + ansible-playbook deploy-edpm.yml |
| 111 | + -i "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml" |
| 112 | + -e @group_vars/all.yml |
| 113 | + -e @scenarios/centos-9/base.yml |
| 114 | + -e @scenarios/centos-9/edpm_baremetal_deployment_ci.yml |
| 115 | + {%- if edpm_file.stat.exists %} |
| 116 | + -e @{{ ansible_user_dir }}/ci-framework-data/artifacts/edpm-ansible.yml |
| 117 | + {%- endif %} |
| 118 | + {%- if cifmw_extras is defined %} |
| 119 | + {%- for extra_var in cifmw_extras %} |
| 120 | + -e "{{ extra_var }}" |
| 121 | + {%- endfor %} |
| 122 | + {%- endif %} |
| 123 | + -e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml" |
| 124 | + -e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/operator_build_output_fr4.yml" |
| 125 | +
|
| 126 | + # Load install_yamls environment from parameters file created by deploy-edpm.yml bootstrap |
| 127 | + # This file should exist after Phase 1 completes successfully |
| 128 | + # Use dir to load all parameter files (similar to playbooks/06-deploy-edpm.yml) |
| 129 | + # This loads all YAML files from the parameters directory directly into the current namespace |
| 130 | + - name: Load parameters files |
| 131 | + ansible.builtin.include_vars: |
| 132 | + dir: "{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters" |
| 133 | + when: cifmw_install_yamls_environment is not defined |
| 134 | + |
| 135 | + - name: Set install_yamls environment for PR update phase |
| 136 | + ansible.builtin.set_fact: |
| 137 | + cifmw_minor_update_pr_env: >- |
| 138 | + {{ |
| 139 | + (cifmw_install_yamls_environment | default({})) | |
| 140 | + combine({'PATH': cifmw_path}) | |
| 141 | + combine({'OPENSTACK_IMG': cifmw_minor_update_pr_index_image}) |
| 142 | + }} |
| 143 | +
|
| 144 | + - name: Phase 2 - Update with PR index image |
| 145 | + block: |
| 146 | + - name: Run make openstack_cleanup |
| 147 | + vars: |
| 148 | + make_openstack_cleanup_env: "{{ cifmw_minor_update_pr_env }}" |
| 149 | + make_openstack_cleanup_dryrun: false |
| 150 | + ansible.builtin.include_role: |
| 151 | + name: 'install_yamls_makes' |
| 152 | + tasks_from: 'make_openstack_cleanup' |
| 153 | + ignore_errors: true # Continue even if cleanup fails |
| 154 | + |
| 155 | + - name: Run make openstack_wait (PR) |
| 156 | + vars: |
| 157 | + make_openstack_wait_env: "{{ cifmw_minor_update_pr_env }}" |
| 158 | + make_openstack_wait_dryrun: false |
| 159 | + ansible.builtin.include_role: |
| 160 | + name: 'install_yamls_makes' |
| 161 | + tasks_from: 'make_openstack_wait' |
| 162 | + |
| 163 | + - name: Run make openstack_init (PR) |
| 164 | + vars: |
| 165 | + make_openstack_init_env: "{{ cifmw_minor_update_pr_env }}" |
| 166 | + make_openstack_init_dryrun: false |
| 167 | + ansible.builtin.include_role: |
| 168 | + name: 'install_yamls_makes' |
| 169 | + tasks_from: 'make_openstack_init' |
| 170 | + |
| 171 | + - name: Get target version from OpenStackVersion CR |
| 172 | + kubernetes.core.k8s_info: |
| 173 | + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
| 174 | + api_key: "{{ cifmw_openshift_token | default(omit) }}" |
| 175 | + context: "{{ cifmw_openshift_context | default(omit) }}" |
| 176 | + api_version: core.openstack.org/v1beta1 |
| 177 | + kind: OpenStackVersion |
| 178 | + namespace: "{{ cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') }}" |
| 179 | + register: openstackversion_info |
| 180 | + retries: 10 |
| 181 | + delay: 5 |
| 182 | + until: > |
| 183 | + openstackversion_info.resources is defined and |
| 184 | + openstackversion_info.resources | length > 0 and |
| 185 | + ( |
| 186 | + (openstackversion_info.resources[0].spec.targetVersion is defined) or |
| 187 | + (openstackversion_info.resources[0].status.availableVersion is defined) |
| 188 | + ) |
| 189 | +
|
| 190 | + - name: Set target version from OpenStackVersion CR |
| 191 | + ansible.builtin.set_fact: |
| 192 | + cifmw_minor_update_target_version: >- |
| 193 | + {{ |
| 194 | + openstackversion_info.resources[0].spec.targetVersion |
| 195 | + if (openstackversion_info.resources[0].spec.targetVersion is defined) |
| 196 | + else openstackversion_info.resources[0].status.availableVersion |
| 197 | + }} |
| 198 | +
|
| 199 | + - name: Run make openstack_update_run with OPENSTACK_VERSION from OpenStackVersion CR |
| 200 | + vars: |
| 201 | + make_openstack_update_run_env: "{{ cifmw_minor_update_pr_env }}" |
| 202 | + make_openstack_update_run_params: |
| 203 | + OPENSTACK_VERSION: "{{ cifmw_minor_update_target_version }}" |
| 204 | + make_openstack_update_run_dryrun: false |
| 205 | + ansible.builtin.include_role: |
| 206 | + name: 'install_yamls_makes' |
| 207 | + tasks_from: 'make_openstack_update_run' |
| 208 | + |
| 209 | + - name: Verify deployed version matches target version |
| 210 | + kubernetes.core.k8s_info: |
| 211 | + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
| 212 | + api_key: "{{ cifmw_openshift_token | default(omit) }}" |
| 213 | + context: "{{ cifmw_openshift_context | default(omit) }}" |
| 214 | + api_version: core.openstack.org/v1beta1 |
| 215 | + kind: OpenStackVersion |
| 216 | + namespace: "{{ cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') }}" |
| 217 | + register: openstackversion_verify_info |
| 218 | + until: > |
| 219 | + openstackversion_verify_info.resources is defined and |
| 220 | + openstackversion_verify_info.resources | length > 0 and |
| 221 | + openstackversion_verify_info.resources[0].status.deployedVersion is defined and |
| 222 | + openstackversion_verify_info.resources[0].status.deployedVersion == cifmw_minor_update_target_version |
| 223 | + retries: 5 |
| 224 | + delay: 2 |
| 225 | + |
| 226 | + - name: Display update verification result |
| 227 | + ansible.builtin.debug: |
| 228 | + msg: >- |
| 229 | + Update verification successful: Target version {{ cifmw_minor_update_target_version }} |
| 230 | + matches deployed version {{ openstackversion_verify_info.resources[0].status.deployedVersion }} |
0 commit comments