Skip to content

Commit a94e475

Browse files
committed
Add new job to run minor update with baremetal deployment
Signed-off-by: rabi <[email protected]>
1 parent 84c46b6 commit a94e475

File tree

4 files changed

+297
-0
lines changed

4 files changed

+297
-0
lines changed
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
---
2+
- name: "Run ci/playbooks/edpm_baremetal_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 minor update index image from content provider or use default
75+
ansible.builtin.set_fact:
76+
cifmw_minor_update_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+
'cifmw_operator_build_output': {
91+
'operators': {
92+
'openstack-operator': {
93+
'image_catalog': cifmw_minor_update_fr4_index_image
94+
}
95+
}
96+
}
97+
}
98+
}}
99+
100+
- name: Phase 1 - Deploy with FR4 index image using deploy-edpm.yml
101+
block:
102+
- name: Write FR4 operator build output to temporary file
103+
ansible.builtin.copy:
104+
dest: "{{ ansible_user_dir }}/ci-framework-data/artifacts/operator_build_output_fr4.yml"
105+
content: "{{ cifmw_operator_build_output_fr4 | to_nice_yaml }}"
106+
mode: "0644"
107+
108+
- name: Perform Podified and EDPM deployment on compute nodes with virtual baremetal (FR4)
109+
ansible.builtin.command:
110+
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework"
111+
cmd: >-
112+
ansible-playbook deploy-edpm.yml
113+
-i "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml"
114+
-e @group_vars/all.yml
115+
-e @scenarios/centos-9/base.yml
116+
-e @scenarios/centos-9/edpm_baremetal_deployment_ci.yml
117+
{%- if edpm_file.stat.exists %}
118+
-e @{{ ansible_user_dir }}/ci-framework-data/artifacts/edpm-ansible.yml
119+
{%- endif %}
120+
{%- if cifmw_extras is defined %}
121+
{%- for extra_var in cifmw_extras %}
122+
-e "{{ extra_var }}"
123+
{%- endfor %}
124+
{%- endif %}
125+
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml"
126+
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/operator_build_output_fr4.yml"
127+
128+
# Load install_yamls environment from parameters file created by deploy-edpm.yml bootstrap
129+
# deploy-edpm.yml runs on target host, so files are on target host
130+
# Use slurp to read from target host, then parse with from_yaml
131+
- name: Read install-yamls-params.yml file from target host
132+
ansible.builtin.slurp:
133+
src: "{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/install-yamls-params.yml"
134+
register: install_yamls_params_content
135+
when: cifmw_install_yamls_environment is not defined
136+
137+
- name: Load install_yamls environment from parameters file
138+
ansible.builtin.set_fact:
139+
cifmw_install_yamls_environment: "{{ (install_yamls_params_content.content | b64decode | from_yaml)['cifmw_install_yamls_environment'] | default({}) }}"
140+
cifmw_install_yamls_defaults: "{{ (install_yamls_params_content.content | b64decode | from_yaml)['cifmw_install_yamls_defaults'] | default({}) }}"
141+
when:
142+
- cifmw_install_yamls_environment is not defined
143+
- install_yamls_params_content.content is defined
144+
145+
- name: Set install_yamls environment for minor update phase
146+
ansible.builtin.set_fact:
147+
cifmw_minor_update_env: >-
148+
{{
149+
(cifmw_install_yamls_environment | default({})) |
150+
combine({'PATH': cifmw_path | default(ansible_user_dir ~ '/.crc/bin:' ~ ansible_user_dir ~ '/.crc/bin/oc:' ~ ansible_user_dir ~ '/bin:' ~ ansible_env.PATH)}) |
151+
combine({'OPENSTACK_IMG': cifmw_minor_update_index_image}) |
152+
combine({'BMO_CLEANUP': false})
153+
}}
154+
155+
# Phase 2: Run update playbook in same execution context as deploy-edpm.yml
156+
# This allows it to use install_yamls_makes role that was generated during Phase 1 bootstrap
157+
- name: Phase 2 - Update with index image for minor update
158+
block:
159+
- name: Write minor update environment to temporary file
160+
ansible.builtin.copy:
161+
dest: "{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/minor_update_env.yml"
162+
content: "{{ {'cifmw_minor_update_env': cifmw_minor_update_env} | to_nice_yaml }}"
163+
mode: "0644"
164+
165+
- name: Run Phase 2 update playbook for minor update
166+
ansible.builtin.command:
167+
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework"
168+
cmd: >-
169+
ansible-playbook ci/playbooks/edpm_baremetal_update/update.yml
170+
-i "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml"
171+
-e @group_vars/all.yml
172+
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml"
173+
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/minor_update_env.yml"
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
# Phase 2: Update with index image for minor update
3+
# This playbook runs in the same execution context as deploy-edpm.yml,
4+
# so it can use install_yamls_makes role that was generated during bootstrap
5+
- name: Phase 2 - Update with index image for minor update
6+
hosts: "{{ cifmw_target_host | default('localhost') }}"
7+
gather_facts: false
8+
tasks:
9+
- name: Filter out host if needed
10+
when:
11+
- cifmw_zuul_target_host is defined
12+
- cifmw_zuul_target_host != 'all'
13+
- inventory_hostname != cifmw_zuul_target_host
14+
ansible.builtin.meta: end_host
15+
16+
- name: Set cifmw_basedir if not defined
17+
ansible.builtin.set_fact:
18+
cifmw_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}"
19+
20+
- name: Load parameters files
21+
ansible.builtin.include_vars:
22+
dir: "{{ cifmw_basedir }}/artifacts/parameters"
23+
24+
- name: Run make openstack_cleanup
25+
vars:
26+
make_openstack_cleanup_env: "{{ cifmw_minor_update_env }}"
27+
make_openstack_cleanup_dryrun: false
28+
ansible.builtin.include_role:
29+
name: 'install_yamls_makes'
30+
tasks_from: 'make_openstack_cleanup'
31+
ignore_errors: true # Continue even if cleanup fails
32+
33+
- name: Run make openstack_wait (minor update)
34+
vars:
35+
make_openstack_wait_env: "{{ cifmw_minor_update_env }}"
36+
make_openstack_wait_dryrun: false
37+
ansible.builtin.include_role:
38+
name: 'install_yamls_makes'
39+
tasks_from: 'make_openstack_wait'
40+
41+
- name: Run make openstack_init (minor update)
42+
vars:
43+
make_openstack_init_env: "{{ cifmw_minor_update_env }}"
44+
make_openstack_init_dryrun: false
45+
ansible.builtin.include_role:
46+
name: 'install_yamls_makes'
47+
tasks_from: 'make_openstack_init'
48+
49+
- name: Get target version from OpenStackVersion CR
50+
kubernetes.core.k8s_info:
51+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
52+
api_key: "{{ cifmw_openshift_token | default(omit) }}"
53+
context: "{{ cifmw_openshift_context | default(omit) }}"
54+
api_version: core.openstack.org/v1beta1
55+
kind: OpenStackVersion
56+
namespace: "{{ cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') }}"
57+
register: openstackversion_info
58+
retries: 10
59+
delay: 5
60+
until: >
61+
openstackversion_info.resources is defined and
62+
openstackversion_info.resources | length > 0 and
63+
(
64+
(openstackversion_info.resources[0].spec.targetVersion is defined) or
65+
(openstackversion_info.resources[0].status.availableVersion is defined)
66+
)
67+
68+
- name: Set target version from OpenStackVersion CR
69+
ansible.builtin.set_fact:
70+
cifmw_minor_update_target_version: >-
71+
{{
72+
openstackversion_info.resources[0].spec.targetVersion
73+
if (openstackversion_info.resources[0].spec.targetVersion is defined)
74+
else openstackversion_info.resources[0].status.availableVersion
75+
}}
76+
77+
- name: Run make openstack_update_run with OPENSTACK_VERSION from OpenStackVersion CR
78+
vars:
79+
make_openstack_update_run_env: "{{ cifmw_minor_update_env }}"
80+
make_openstack_update_run_params:
81+
OPENSTACK_VERSION: "{{ cifmw_minor_update_target_version }}"
82+
make_openstack_update_run_dryrun: false
83+
ansible.builtin.include_role:
84+
name: 'install_yamls_makes'
85+
tasks_from: 'make_openstack_update_run'
86+
87+
- name: Verify deployed version matches target version
88+
kubernetes.core.k8s_info:
89+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
90+
api_key: "{{ cifmw_openshift_token | default(omit) }}"
91+
context: "{{ cifmw_openshift_context | default(omit) }}"
92+
api_version: core.openstack.org/v1beta1
93+
kind: OpenStackVersion
94+
namespace: "{{ cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') }}"
95+
register: openstackversion_verify_info
96+
until: >
97+
openstackversion_verify_info.resources is defined and
98+
openstackversion_verify_info.resources | length > 0 and
99+
openstackversion_verify_info.resources[0].status.deployedVersion is defined and
100+
openstackversion_verify_info.resources[0].status.deployedVersion == cifmw_minor_update_target_version
101+
retries: 5
102+
delay: 2
103+
104+
- name: Display update verification result
105+
ansible.builtin.debug:
106+
msg: >-
107+
Update verification successful: Target version {{ cifmw_minor_update_target_version }}
108+
matches deployed version {{ openstackversion_verify_info.resources[0].status.deployedVersion }}

zuul.d/edpm.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@
3939
cifmw_edpm_deploy_baremetal_bootc: true
4040
cifmw_update_containers: true
4141

42+
# Virtual Baremetal job with CRC for minor update testing.
43+
# First deploys with FR4 index image, then updates with PR index image.
44+
- job:
45+
name: cifmw-crc-podified-edpm-baremetal-minor-update
46+
nodeset: centos-9-crc-2-48-0-6xlarge
47+
parent: cifmw-base-crc-openstack
48+
run: ci/playbooks/edpm_baremetal_update/run.yml
49+
dependencies:
50+
- openstack-k8s-operators-content-provider
51+
vars:
52+
crc_parameters: "--memory 32000 --disk-size 240 --cpus 12"
53+
cifmw_manage_secrets_pullsecret_content: '{}'
54+
cifmw_rhol_crc_binary_folder: "/usr/local/bin"
55+
cifmw_minor_update_pre_update_tag: "18.0-fr4-latest"
56+
4257
# Podified galera job
4358
- job:
4459
name: cifmw-crc-podified-galera-deployment

zuul.d/project-templates.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
- cifmw-molecule
6060
- podified-multinode-edpm-deployment-crc: *content_provider
6161
- cifmw-crc-podified-edpm-baremetal: *content_provider
62+
- cifmw-crc-podified-edpm-baremetal-minor-update: *content_provider
6263
- podified-multinode-hci-deployment-crc: *content_provider
6364
- cifmw-multinode-tempest: *content_provider
6465
- cifmw-pod-zuul-files

0 commit comments

Comments
 (0)