Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions ci/playbooks/edpm_baremetal_update/run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
- name: "Run ci/playbooks/edpm_baremetal_update/run.yml"
hosts: "{{ cifmw_zuul_target_host | default('all') }}"
gather_facts: true
tasks:
- name: Filter out host if needed
when:
- cifmw_zuul_target_host is defined
- cifmw_zuul_target_host != 'all'
- inventory_hostname != cifmw_zuul_target_host
ansible.builtin.meta: end_host

- name: Check for edpm-ansible.yml file
ansible.builtin.stat:
path: "{{ ansible_user_dir }}/ci-framework-data/artifacts/edpm-ansible.yml"
register: edpm_file

- name: Check if new ssh keypair exists
ansible.builtin.include_role:
name: recognize_ssh_keypair

- name: Add crc node in local inventory
ansible.builtin.add_host:
name: crc
ansible_ssh_private_key_file: "{{ ansible_user_dir }}/.crc/machines/crc/{{ crc_ssh_keypair }}"
ansible_ssh_user: core
ansible_host: api.crc.testing

- name: Ensure we know ssh hosts
ansible.builtin.shell:
cmd: "ssh-keyscan {{ hostvars[item].ansible_host }} >> ~/.ssh/known_hosts"
loop: "{{ hostvars.keys() | reject('equalto', 'localhost') }}"

- name: Inject CRC in zuul_inventory
block:
- name: Load zuul_inventory
register: _inventory
ansible.builtin.slurp:
path: "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml"

- name: Inject CRC in zuul_inventory.yml
vars:
_crc:
all:
hosts:
crc: "{{ dict(hostvars.crc) }}"
_updated: >-
{{
_inventory.content | b64decode | from_yaml | combine(_crc, recursive=true)
}}
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml"
content: "{{ _updated | to_nice_yaml }}"
mode: "0644"

- name: Set default pre-update tag if not provided
ansible.builtin.set_fact:
cifmw_minor_update_pre_update_tag: "{{ cifmw_minor_update_pre_update_tag | default('18.0-fr3-latest') }}"

- name: Get pre-update index image digest from tag
ansible.builtin.shell: >-
skopeo inspect
docker://quay.io/openstack-k8s-operators/openstack-operator-index:{{ cifmw_minor_update_pre_update_tag }}
| jq -r '.Digest'
register: pre_update_digest_result
changed_when: false
failed_when: pre_update_digest_result.rc != 0

- name: Set pre-update index image using digest from tag
ansible.builtin.set_fact:
cifmw_minor_update_pre_update_index_image: >-
quay.io/openstack-k8s-operators/openstack-operator-index@{{ pre_update_digest_result.stdout | trim }}

- name: Get minor update index image from content provider or use default
ansible.builtin.set_fact:
cifmw_minor_update_index_image: >-
{{
cifmw_operator_build_output.operators['openstack-operator'].image_catalog
if (cifmw_operator_build_output is defined and
cifmw_operator_build_output.operators is defined and
'openstack-operator' in cifmw_operator_build_output.operators)
else cifmw_minor_update_pre_update_index_image
}}

- name: Override operator build output with pre-update index image for Phase 1
ansible.builtin.set_fact:
cifmw_operator_build_output_pre_update: >-
{{
{
'cifmw_operator_build_output': {
'operators': {
'openstack-operator': {
'image_catalog': cifmw_minor_update_pre_update_index_image
}
}
}
}
}}

- name: Phase 1 - Deploy with pre-update index image using deploy-edpm.yml
block:
- name: Write pre-update operator build output to temporary file
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/ci-framework-data/artifacts/operator_build_output_pre_update.yml"
content: "{{ cifmw_operator_build_output_pre_update | to_nice_yaml }}"
mode: "0644"

- name: Perform Podified and EDPM deployment on compute nodes with virtual baremetal (pre-update)
ansible.builtin.command:
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework"
cmd: >-
ansible-playbook deploy-edpm.yml
-i "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml"
-e @group_vars/all.yml
-e @scenarios/centos-9/base.yml
-e @scenarios/centos-9/edpm_baremetal_deployment_ci.yml
{%- if edpm_file.stat.exists %}
-e @{{ ansible_user_dir }}/ci-framework-data/artifacts/edpm-ansible.yml
{%- endif %}
{%- if cifmw_extras is defined %}
{%- for extra_var in cifmw_extras %}
-e "{{ extra_var }}"
{%- endfor %}
{%- endif %}
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml"
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/operator_build_output_pre_update.yml"
-e "cifmw_prepare_openstackversion=false"
233 changes: 233 additions & 0 deletions ci/playbooks/edpm_baremetal_update/update-edpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
---
# CI playbook for OpenStack minor version updates.
# This playbook performs a minor version update of an OpenStack deployment
# using index images and install_yamls make targets.
# This playbook depends on content provider variables from CI jobs.
# It runs on cifmw_target_host in the same execution context as deploy-edpm.yml,
# so it can use the install_yamls_makes role that was generated during bootstrap.

- name: OpenStack minor version update
hosts: "{{ cifmw_target_host | default('localhost') }}"
gather_facts: false
tasks:
- name: Set cifmw_basedir if not defined
ansible.builtin.set_fact:
cifmw_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}"

- name: Set update artifacts basedir if not defined
ansible.builtin.set_fact:
cifmw_update_artifacts_basedir: "{{ cifmw_update_artifacts_basedir | default(cifmw_basedir ~ '/tests/update') }}"

- name: Initialize monitoring
ansible.builtin.include_role:
name: update
tasks_from: init_monitoring.yml

- name: Load parameters files
ansible.builtin.include_vars:
dir: "{{ cifmw_basedir }}/artifacts/parameters"

- name: Set install_yamls environment for minor update phase
ansible.builtin.set_fact:
cifmw_minor_update_env: >-
{{
(cifmw_install_yamls_environment | default({})) |
combine({'PATH': cifmw_path | default(ansible_user_dir ~ '/.crc/bin:' ~ ansible_user_dir ~ '/.crc/bin/oc:' ~ ansible_user_dir ~ '/bin:' ~ ansible_env.PATH)}) |
combine({'OPENSTACK_IMG': cifmw_minor_update_index_image}) |
combine({'BMO_CLEANUP': false})
}}

- name: Set update step to Running openstack cleanup
ansible.builtin.command:
cmd: >
{{ cifmw_update_artifacts_basedir }}/update_event.sh
Running openstack cleanup

- name: Run make openstack_cleanup
vars:
make_openstack_cleanup_env: "{{ cifmw_minor_update_env }}"
make_openstack_cleanup_dryrun: false
ansible.builtin.include_role:
name: 'install_yamls_makes'
tasks_from: 'make_openstack_cleanup'
ignore_errors: true # Continue even if cleanup fails

- name: Set update step to Running openstack wait
ansible.builtin.command:
cmd: >
{{ cifmw_update_artifacts_basedir }}/update_event.sh
Running openstack wait

- name: Run make openstack_wait (minor update)
vars:
make_openstack_wait_env: "{{ cifmw_minor_update_env }}"
make_openstack_wait_dryrun: false
ansible.builtin.include_role:
name: 'install_yamls_makes'
tasks_from: 'make_openstack_wait'

- name: Set update step to Running openstack init
ansible.builtin.command:
cmd: >
{{ cifmw_update_artifacts_basedir }}/update_event.sh
Running openstack init

- name: Run make openstack_init (minor update)
vars:
make_openstack_init_env: "{{ cifmw_minor_update_env }}"
make_openstack_init_dryrun: false
ansible.builtin.include_role:
name: 'install_yamls_makes'
tasks_from: 'make_openstack_init'

- name: Set update step to Waiting for new version to be available
ansible.builtin.command:
cmd: >
{{ cifmw_update_artifacts_basedir }}/update_event.sh
Waiting for new version to be available

- name: Wait for availableVersion to be different from deployedVersion
kubernetes.core.k8s_info:
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
api_key: "{{ cifmw_openshift_token | default(omit) }}"
context: "{{ cifmw_openshift_context | default(omit) }}"
api_version: core.openstack.org/v1beta1
kind: OpenStackVersion
namespace: "{{ cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') }}"
register: openstackversion_wait_info
retries: 10
delay: 60
until: >
openstackversion_wait_info.resources is defined and
openstackversion_wait_info.resources | length > 0 and
openstackversion_wait_info.resources[0].status.availableVersion is defined and
openstackversion_wait_info.resources[0].status.deployedVersion is defined and
openstackversion_wait_info.resources[0].status.availableVersion != openstackversion_wait_info.resources[0].status.deployedVersion

- name: Get available version from OpenStackVersion CR
ansible.builtin.set_fact:
cifmw_minor_update_target_version: "{{ openstackversion_wait_info.resources[0].status.availableVersion }}"

- name: Set update step to Patching OpenStackVersion CR
ansible.builtin.command:
cmd: >
{{ cifmw_update_artifacts_basedir }}/update_event.sh
Patching OpenStackVersion CR with version {{ cifmw_minor_update_target_version }}

- name: Patch OpenStackVersion CR availableVersion
vars:
make_openstack_patch_version_env: "{{ cifmw_minor_update_env }}"
make_openstack_patch_version_dryrun: false
ansible.builtin.include_role:
name: 'install_yamls_makes'
tasks_from: 'make_openstack_patch_version'

- name: Set vars related to update_containers content provider
when:
- content_provider_os_registry_url is defined
- content_provider_os_registry_url != 'null'
ansible.builtin.set_fact:
cifmw_update_containers_registry: "{{ content_provider_os_registry_url | split('/') | first }}"
cifmw_update_containers_org: "{{ content_provider_os_registry_url | split('/') | last }}"
cifmw_update_containers_tag: "{{ content_provider_dlrn_md5_hash }}"
cifmw_update_containers_openstack: true

- name: Set update step to Updating container images
when: >-
(cifmw_update_containers_edpm_image_url is defined and
cifmw_update_containers_openstack is defined and
cifmw_update_containers_openstack | bool) or
(cifmw_update_containers_ansibleee_image_url is defined) or
(cifmw_update_containers_openstack is defined and
cifmw_update_containers_openstack | bool) or
(cifmw_update_containers_watcher is defined and
cifmw_update_containers_watcher | bool)
ansible.builtin.command:
cmd: >
{{ cifmw_update_artifacts_basedir }}/update_event.sh
Updating container images

- name: Prepare and patch OpenStackVersion CR for update
vars:
cifmw_update_containers_metadata: "controlplane"
cifmw_update_containers: true
ansible.builtin.include_role:
name: update_containers
when: >-
(cifmw_update_containers_edpm_image_url is defined and
cifmw_update_containers_openstack is defined and
cifmw_update_containers_openstack | bool) or
(cifmw_update_containers_ansibleee_image_url is defined) or
(cifmw_update_containers_openstack is defined and
cifmw_update_containers_openstack | bool) or
( cifmw_update_containers_watcher is defined and
cifmw_update_containers_watcher | bool)

- name: Set update step to Starting the CI update sequence
ansible.builtin.command:
cmd: >
{{ cifmw_update_artifacts_basedir }}/update_event.sh
Starting the CI update sequence

- name: Run make openstack_update_run
vars:
make_openstack_update_run_env: "{{ cifmw_minor_update_env }}"
make_openstack_update_run_params:
TIMEOUT: "1200s"
OPENSTACK_VERSION: "{{ cifmw_minor_update_target_version }}"
make_openstack_update_run_dryrun: false
ansible.builtin.include_role:
name: 'install_yamls_makes'
tasks_from: 'make_openstack_update_run'

- name: Set update step to Verifying update completion
ansible.builtin.command:
cmd: >
{{ cifmw_update_artifacts_basedir }}/update_event.sh
Verifying update completion

- name: Verify deployed version matches target version
kubernetes.core.k8s_info:
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
api_key: "{{ cifmw_openshift_token | default(omit) }}"
context: "{{ cifmw_openshift_context | default(omit) }}"
api_version: core.openstack.org/v1beta1
kind: OpenStackVersion
namespace: "{{ cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') }}"
register: openstackversion_verify_info
until: >
openstackversion_verify_info.resources is defined and
openstackversion_verify_info.resources | length > 0 and
openstackversion_verify_info.resources[0].status.deployedVersion is defined and
openstackversion_verify_info.resources[0].status.deployedVersion == cifmw_minor_update_target_version
retries: 5
delay: 2

- name: Set update step to CI update sequence complete
ansible.builtin.command:
cmd: >
{{ cifmw_update_artifacts_basedir }}/update_event.sh
CI update verification successful - Target version {{ cifmw_minor_update_target_version }}
matches deployed version {{ openstackversion_verify_info.resources[0].status.deployedVersion }}

- name: Display update verification result
ansible.builtin.debug:
msg: >-
Update verification successful: Target version {{ cifmw_minor_update_target_version }}
matches deployed version {{ openstackversion_verify_info.resources[0].status.deployedVersion }}

- name: Stop monitoring
block:
- name: Verify monitoring pid file
ansible.builtin.stat:
path: "{{ cifmw_update_artifacts_basedir }}/monitor_resources_changes.pid"
register: cifmw_update_monitoring_pid

- name: Stop the monitoring process
ansible.builtin.shell:
cmd: >-
kill
$(cat {{ cifmw_update_artifacts_basedir }}/monitor_resources_changes.pid)
register: _kill_result
failed_when: _kill_result.rc not in [0, 1]
when: cifmw_update_monitoring_pid.stat.exists | bool
Loading