|
| 1 | +--- |
| 2 | +# CI playbook for OpenStack minor version updates. |
| 3 | +# This playbook performs a minor version update of an OpenStack deployment |
| 4 | +# using index images and install_yamls make targets. |
| 5 | +# This playbook depends on content provider variables from CI jobs. |
| 6 | +# It runs on cifmw_target_host in the same execution context as deploy-edpm.yml, |
| 7 | +# so it can use the install_yamls_makes role that was generated during bootstrap. |
| 8 | + |
| 9 | +- name: OpenStack minor version update |
| 10 | + hosts: "{{ cifmw_target_host | default('localhost') }}" |
| 11 | + gather_facts: false |
| 12 | + tasks: |
| 13 | + - name: Set cifmw_basedir if not defined |
| 14 | + ansible.builtin.set_fact: |
| 15 | + cifmw_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}" |
| 16 | + |
| 17 | + - name: Set update artifacts basedir if not defined |
| 18 | + ansible.builtin.set_fact: |
| 19 | + cifmw_update_artifacts_basedir: "{{ cifmw_update_artifacts_basedir | default(cifmw_basedir ~ '/tests/update') }}" |
| 20 | + |
| 21 | + - name: Initialize monitoring |
| 22 | + ansible.builtin.include_role: |
| 23 | + name: update |
| 24 | + tasks_from: init_monitoring.yml |
| 25 | + |
| 26 | + - name: Load parameters files |
| 27 | + ansible.builtin.include_vars: |
| 28 | + dir: "{{ cifmw_basedir }}/artifacts/parameters" |
| 29 | + |
| 30 | + - name: Set install_yamls environment for minor update phase |
| 31 | + ansible.builtin.set_fact: |
| 32 | + cifmw_minor_update_env: >- |
| 33 | + {{ |
| 34 | + (cifmw_install_yamls_environment | default({})) | |
| 35 | + combine({'PATH': cifmw_path | default(ansible_user_dir ~ '/.crc/bin:' ~ ansible_user_dir ~ '/.crc/bin/oc:' ~ ansible_user_dir ~ '/bin:' ~ ansible_env.PATH)}) | |
| 36 | + combine({'OPENSTACK_IMG': cifmw_minor_update_index_image}) | |
| 37 | + combine({'BMO_CLEANUP': false}) |
| 38 | + }} |
| 39 | +
|
| 40 | + - name: Set update step to Running openstack cleanup |
| 41 | + ansible.builtin.command: |
| 42 | + cmd: > |
| 43 | + {{ cifmw_update_artifacts_basedir }}/update_event.sh |
| 44 | + Running openstack cleanup |
| 45 | +
|
| 46 | + - name: Run make openstack_cleanup |
| 47 | + vars: |
| 48 | + make_openstack_cleanup_env: "{{ cifmw_minor_update_env }}" |
| 49 | + make_openstack_cleanup_dryrun: false |
| 50 | + ansible.builtin.include_role: |
| 51 | + name: 'install_yamls_makes' |
| 52 | + tasks_from: 'make_openstack_cleanup' |
| 53 | + ignore_errors: true # Continue even if cleanup fails |
| 54 | + |
| 55 | + - name: Set update step to Running openstack wait |
| 56 | + ansible.builtin.command: |
| 57 | + cmd: > |
| 58 | + {{ cifmw_update_artifacts_basedir }}/update_event.sh |
| 59 | + Running openstack wait |
| 60 | +
|
| 61 | + - name: Run make openstack_wait (minor update) |
| 62 | + vars: |
| 63 | + make_openstack_wait_env: "{{ cifmw_minor_update_env }}" |
| 64 | + make_openstack_wait_dryrun: false |
| 65 | + ansible.builtin.include_role: |
| 66 | + name: 'install_yamls_makes' |
| 67 | + tasks_from: 'make_openstack_wait' |
| 68 | + |
| 69 | + - name: Set update step to Running openstack init |
| 70 | + ansible.builtin.command: |
| 71 | + cmd: > |
| 72 | + {{ cifmw_update_artifacts_basedir }}/update_event.sh |
| 73 | + Running openstack init |
| 74 | +
|
| 75 | + - name: Run make openstack_init (minor update) |
| 76 | + vars: |
| 77 | + make_openstack_init_env: "{{ cifmw_minor_update_env }}" |
| 78 | + make_openstack_init_dryrun: false |
| 79 | + ansible.builtin.include_role: |
| 80 | + name: 'install_yamls_makes' |
| 81 | + tasks_from: 'make_openstack_init' |
| 82 | + |
| 83 | + - name: Set update step to Waiting for new version to be available |
| 84 | + ansible.builtin.command: |
| 85 | + cmd: > |
| 86 | + {{ cifmw_update_artifacts_basedir }}/update_event.sh |
| 87 | + Waiting for new version to be available |
| 88 | +
|
| 89 | + - name: Wait for availableVersion to be different from deployedVersion |
| 90 | + kubernetes.core.k8s_info: |
| 91 | + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
| 92 | + api_key: "{{ cifmw_openshift_token | default(omit) }}" |
| 93 | + context: "{{ cifmw_openshift_context | default(omit) }}" |
| 94 | + api_version: core.openstack.org/v1beta1 |
| 95 | + kind: OpenStackVersion |
| 96 | + namespace: "{{ cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') }}" |
| 97 | + register: openstackversion_wait_info |
| 98 | + retries: 10 |
| 99 | + delay: 60 |
| 100 | + until: > |
| 101 | + openstackversion_wait_info.resources is defined and |
| 102 | + openstackversion_wait_info.resources | length > 0 and |
| 103 | + openstackversion_wait_info.resources[0].status.availableVersion is defined and |
| 104 | + openstackversion_wait_info.resources[0].status.deployedVersion is defined and |
| 105 | + openstackversion_wait_info.resources[0].status.availableVersion != openstackversion_wait_info.resources[0].status.deployedVersion |
| 106 | +
|
| 107 | + - name: Get available version from OpenStackVersion CR |
| 108 | + ansible.builtin.set_fact: |
| 109 | + cifmw_minor_update_target_version: "{{ openstackversion_wait_info.resources[0].status.availableVersion }}" |
| 110 | + |
| 111 | + - name: Set update step to Patching OpenStackVersion CR |
| 112 | + ansible.builtin.command: |
| 113 | + cmd: > |
| 114 | + {{ cifmw_update_artifacts_basedir }}/update_event.sh |
| 115 | + Patching OpenStackVersion CR with version {{ cifmw_minor_update_target_version }} |
| 116 | +
|
| 117 | + - name: Patch OpenStackVersion CR availableVersion |
| 118 | + vars: |
| 119 | + make_openstack_patch_version_env: "{{ cifmw_minor_update_env }}" |
| 120 | + make_openstack_patch_version_dryrun: false |
| 121 | + ansible.builtin.include_role: |
| 122 | + name: 'install_yamls_makes' |
| 123 | + tasks_from: 'make_openstack_patch_version' |
| 124 | + |
| 125 | + - name: Set vars related to update_containers content provider |
| 126 | + when: |
| 127 | + - content_provider_os_registry_url is defined |
| 128 | + - content_provider_os_registry_url != 'null' |
| 129 | + ansible.builtin.set_fact: |
| 130 | + cifmw_update_containers_registry: "{{ content_provider_os_registry_url | split('/') | first }}" |
| 131 | + cifmw_update_containers_org: "{{ content_provider_os_registry_url | split('/') | last }}" |
| 132 | + cifmw_update_containers_tag: "{{ content_provider_dlrn_md5_hash }}" |
| 133 | + cifmw_update_containers_openstack: true |
| 134 | + |
| 135 | + - name: Set update step to Updating container images |
| 136 | + when: >- |
| 137 | + (cifmw_update_containers_edpm_image_url is defined and |
| 138 | + cifmw_update_containers_openstack is defined and |
| 139 | + cifmw_update_containers_openstack | bool) or |
| 140 | + (cifmw_update_containers_ansibleee_image_url is defined) or |
| 141 | + (cifmw_update_containers_openstack is defined and |
| 142 | + cifmw_update_containers_openstack | bool) or |
| 143 | + (cifmw_update_containers_watcher is defined and |
| 144 | + cifmw_update_containers_watcher | bool) |
| 145 | + ansible.builtin.command: |
| 146 | + cmd: > |
| 147 | + {{ cifmw_update_artifacts_basedir }}/update_event.sh |
| 148 | + Updating container images |
| 149 | +
|
| 150 | + - name: Prepare and patch OpenStackVersion CR for update |
| 151 | + vars: |
| 152 | + cifmw_update_containers_metadata: "controlplane" |
| 153 | + cifmw_update_containers: true |
| 154 | + ansible.builtin.include_role: |
| 155 | + name: update_containers |
| 156 | + when: >- |
| 157 | + (cifmw_update_containers_edpm_image_url is defined and |
| 158 | + cifmw_update_containers_openstack is defined and |
| 159 | + cifmw_update_containers_openstack | bool) or |
| 160 | + (cifmw_update_containers_ansibleee_image_url is defined) or |
| 161 | + (cifmw_update_containers_openstack is defined and |
| 162 | + cifmw_update_containers_openstack | bool) or |
| 163 | + ( cifmw_update_containers_watcher is defined and |
| 164 | + cifmw_update_containers_watcher | bool) |
| 165 | +
|
| 166 | + - name: Set update step to Starting the CI update sequence |
| 167 | + ansible.builtin.command: |
| 168 | + cmd: > |
| 169 | + {{ cifmw_update_artifacts_basedir }}/update_event.sh |
| 170 | + Starting the CI update sequence |
| 171 | +
|
| 172 | + - name: Run make openstack_update_run |
| 173 | + vars: |
| 174 | + make_openstack_update_run_env: "{{ cifmw_minor_update_env }}" |
| 175 | + make_openstack_update_run_params: |
| 176 | + OPENSTACK_VERSION: "{{ cifmw_minor_update_target_version }}" |
| 177 | + make_openstack_update_run_dryrun: false |
| 178 | + ansible.builtin.include_role: |
| 179 | + name: 'install_yamls_makes' |
| 180 | + tasks_from: 'make_openstack_update_run' |
| 181 | + |
| 182 | + - name: Set update step to Verifying update completion |
| 183 | + ansible.builtin.command: |
| 184 | + cmd: > |
| 185 | + {{ cifmw_update_artifacts_basedir }}/update_event.sh |
| 186 | + Verifying update completion |
| 187 | +
|
| 188 | + - name: Verify deployed version matches target version |
| 189 | + kubernetes.core.k8s_info: |
| 190 | + kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
| 191 | + api_key: "{{ cifmw_openshift_token | default(omit) }}" |
| 192 | + context: "{{ cifmw_openshift_context | default(omit) }}" |
| 193 | + api_version: core.openstack.org/v1beta1 |
| 194 | + kind: OpenStackVersion |
| 195 | + namespace: "{{ cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') }}" |
| 196 | + register: openstackversion_verify_info |
| 197 | + until: > |
| 198 | + openstackversion_verify_info.resources is defined and |
| 199 | + openstackversion_verify_info.resources | length > 0 and |
| 200 | + openstackversion_verify_info.resources[0].status.deployedVersion is defined and |
| 201 | + openstackversion_verify_info.resources[0].status.deployedVersion == cifmw_minor_update_target_version |
| 202 | + retries: 5 |
| 203 | + delay: 2 |
| 204 | + |
| 205 | + - name: Set update step to CI update sequence complete |
| 206 | + ansible.builtin.command: |
| 207 | + cmd: > |
| 208 | + {{ cifmw_update_artifacts_basedir }}/update_event.sh |
| 209 | + CI update verification successful - Target version {{ cifmw_minor_update_target_version }} |
| 210 | + matches deployed version {{ openstackversion_verify_info.resources[0].status.deployedVersion }} |
| 211 | +
|
| 212 | + - name: Display update verification result |
| 213 | + ansible.builtin.debug: |
| 214 | + msg: >- |
| 215 | + Update verification successful: Target version {{ cifmw_minor_update_target_version }} |
| 216 | + matches deployed version {{ openstackversion_verify_info.resources[0].status.deployedVersion }} |
| 217 | +
|
| 218 | + - name: Stop monitoring |
| 219 | + block: |
| 220 | + - name: Verify monitoring pid file |
| 221 | + ansible.builtin.stat: |
| 222 | + path: "{{ cifmw_update_artifacts_basedir }}/monitor_resources_changes.pid" |
| 223 | + register: cifmw_update_monitoring_pid |
| 224 | + |
| 225 | + - name: Stop the monitoring process |
| 226 | + ansible.builtin.shell: |
| 227 | + cmd: >- |
| 228 | + kill |
| 229 | + $(cat {{ cifmw_update_artifacts_basedir }}/monitor_resources_changes.pid) |
| 230 | + register: _kill_result |
| 231 | + failed_when: _kill_result.rc not in [0, 1] |
| 232 | + when: cifmw_update_monitoring_pid.stat.exists | bool |
| 233 | + |
| 234 | + - name: Run post_update hooks |
| 235 | + vars: |
| 236 | + step: post_update |
| 237 | + ansible.builtin.import_role: |
| 238 | + name: run_hook |
| 239 | + |
| 240 | + - name: Run cifmw_setup run_tests.yml |
| 241 | + when: cifmw_run_tests | default(false) | bool |
| 242 | + vars: |
| 243 | + cifmw_test_operator_artifacts_basedir: "{{ cifmw_basedir|default(ansible_user_dir ~ '/ci-framework-data') }}/tests/test_operator_update" |
| 244 | + cifmw_test_operator_tempest_name: "post-update-tempest-tests" |
| 245 | + ansible.builtin.import_role: |
| 246 | + name: cifmw_setup |
| 247 | + tasks_from: run_tests.yml |
| 248 | + tags: |
| 249 | + - run-tests |
0 commit comments