|
| 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_zuul_target_host where tasks are executed. |
| 7 | +# This playbook should be called after update_prepare.yml which sets up |
| 8 | +# the collection. This playbook generates the install_yamls_makes role |
| 9 | +# and then performs the update. |
| 10 | +# This is Phase 2 of the baremetal update workflow and should be called |
| 11 | +# sequentially after run.yml (Phase 1) and update_prepare.yml. |
| 12 | + |
| 13 | +- name: Ensure install_yamls_makes role exists on zuul host |
| 14 | + hosts: localhost |
| 15 | + gather_facts: false |
| 16 | + tasks: |
| 17 | + - name: Set cifmw_basedir if not defined |
| 18 | + ansible.builtin.set_fact: |
| 19 | + cifmw_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}" |
| 20 | + |
| 21 | + - name: Check if install_yamls_makes role exists |
| 22 | + ansible.builtin.stat: |
| 23 | + path: "{{ ansible_user_dir }}/ci-framework-data/artifacts/roles/install_yamls_makes/tasks" |
| 24 | + register: install_yamls_makes_role_check |
| 25 | + |
| 26 | + - name: Generate install_yamls_makes role on zuul host |
| 27 | + when: not install_yamls_makes_role_check.stat.exists |
| 28 | + ansible.builtin.include_role: |
| 29 | + name: install_yamls |
| 30 | + |
| 31 | +- name: OpenStack minor version update |
| 32 | + hosts: "{{ cifmw_zuul_target_host | default('all') }}" |
| 33 | + gather_facts: false |
| 34 | + tasks: |
| 35 | + - name: Filter out host if needed |
| 36 | + when: |
| 37 | + - cifmw_zuul_target_host is defined |
| 38 | + - cifmw_zuul_target_host != 'all' |
| 39 | + - inventory_hostname != cifmw_zuul_target_host |
| 40 | + ansible.builtin.meta: end_host |
| 41 | + |
| 42 | + - name: Set cifmw_basedir if not defined |
| 43 | + ansible.builtin.set_fact: |
| 44 | + cifmw_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}" |
| 45 | + |
| 46 | + - name: Set update artifacts basedir if not defined |
| 47 | + ansible.builtin.set_fact: |
| 48 | + cifmw_update_artifacts_basedir: "{{ cifmw_update_artifacts_basedir | default(cifmw_basedir ~ '/tests/update') }}" |
| 49 | + |
| 50 | + - name: Set cifmw_openshift_kubeconfig if not defined |
| 51 | + ansible.builtin.set_fact: |
| 52 | + cifmw_openshift_kubeconfig: "{{ cifmw_openshift_kubeconfig | default(ansible_user_dir ~ '/.crc/machines/crc/kubeconfig') }}" |
| 53 | + |
| 54 | + - name: Get minor update index image from content provider or use default |
| 55 | + ansible.builtin.set_fact: |
| 56 | + cifmw_minor_update_index_image: >- |
| 57 | + {{ |
| 58 | + cifmw_operator_build_output.operators['openstack-operator'].image_catalog |
| 59 | + if (cifmw_operator_build_output is defined and |
| 60 | + cifmw_operator_build_output.operators is defined and |
| 61 | + 'openstack-operator' in cifmw_operator_build_output.operators) |
| 62 | + else cifmw_minor_update_pre_update_index_image | default('quay.io/openstack-k8s-operators/openstack-operator-index:18.0-fr3-latest') |
| 63 | + }} |
| 64 | +
|
| 65 | + - name: Write minor update index image to parameters file |
| 66 | + ansible.builtin.copy: |
| 67 | + dest: "{{ cifmw_basedir }}/artifacts/parameters/minor_update_index_image.yml" |
| 68 | + content: "{{ {'cifmw_minor_update_index_image': cifmw_minor_update_index_image} | to_nice_yaml }}" |
| 69 | + mode: "0644" |
| 70 | + when: cifmw_minor_update_index_image is defined |
| 71 | + |
| 72 | + - name: Initialize monitoring |
| 73 | + ansible.builtin.include_role: |
| 74 | + name: update |
| 75 | + tasks_from: init_monitoring.yml |
| 76 | + |
| 77 | + - name: Load parameters from files on current host |
| 78 | + # Parameters files exist on cifmw_zuul_target_host. |
| 79 | + # Use var_dir.yml to read files directly from the current host and set them as facts. |
| 80 | + vars: |
| 81 | + provided_dir: "{{ cifmw_basedir }}/artifacts/parameters" |
| 82 | + ansible.builtin.include_role: |
| 83 | + name: cifmw_helpers |
| 84 | + tasks_from: var_dir.yml |
| 85 | + |
| 86 | + - name: Debug cifmw_install_yamls_environment after loading parameters |
| 87 | + ansible.builtin.debug: |
| 88 | + msg: "cifmw_install_yamls_environment: {{ cifmw_install_yamls_environment | default('UNDEFINED') | to_nice_yaml }}" |
| 89 | + |
| 90 | + - name: Debug cifmw_install_yamls_defaults after loading parameters |
| 91 | + ansible.builtin.debug: |
| 92 | + msg: "cifmw_install_yamls_defaults: {{ cifmw_install_yamls_defaults | default('UNDEFINED') | to_nice_yaml }}" |
| 93 | + |
| 94 | + - name: Set install_yamls environment for minor update phase |
| 95 | + ansible.builtin.set_fact: |
| 96 | + cifmw_minor_update_env: >- |
| 97 | + {{ |
| 98 | + (cifmw_install_yamls_environment | default({})) | |
| 99 | + combine({'PATH': cifmw_path | default(ansible_user_dir ~ '/.crc/bin:' ~ ansible_user_dir ~ '/.crc/bin/oc:' ~ ansible_user_dir ~ '/bin:' ~ ansible_env.PATH)}) | |
| 100 | + combine({'OPENSTACK_IMG': cifmw_minor_update_index_image}) | |
| 101 | + combine({'BMO_CLEANUP': false}) |
| 102 | + }} |
| 103 | +
|
| 104 | + - name: Set vars related to update_containers content provider |
| 105 | + when: |
| 106 | + - content_provider_os_registry_url is defined |
| 107 | + - content_provider_os_registry_url != 'null' |
| 108 | + ansible.builtin.set_fact: |
| 109 | + cifmw_update_containers_registry: "{{ content_provider_os_registry_url | split('/') | first }}" |
| 110 | + cifmw_update_containers_org: "{{ content_provider_os_registry_url | split('/') | last }}" |
| 111 | + cifmw_update_containers_tag: "{{ content_provider_dlrn_md5_hash }}" |
| 112 | + cifmw_update_containers_openstack: true |
| 113 | + |
| 114 | + - name: Run update variant ci |
| 115 | + vars: |
| 116 | + cifmw_update_variant: ci |
| 117 | + cifmw_update_cleanup_ignore_errors: true |
| 118 | + cifmw_update_openstack_update_run_timeout: "1200s" |
| 119 | + cifmw_update_display_verification_result: true |
| 120 | + cifmw_update_stop_monitoring: true |
| 121 | + ansible.builtin.include_role: |
| 122 | + name: update |
| 123 | + tasks_from: update_variant_ci.yml |
0 commit comments