Skip to content

Commit 7ffc558

Browse files
committed
DNM Testing alternate approach
Adds a new baremetal job to test minor update with upstream github content. This will currently test from fr3->main(with PR). Signed-off-by: rabi <ramishra@redhat.com>
1 parent 84c46b6 commit 7ffc558

File tree

12 files changed

+642
-5
lines changed

12 files changed

+642
-5
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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-fr3-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: pre_update_digest_result
66+
changed_when: false
67+
failed_when: pre_update_digest_result.rc != 0
68+
69+
- name: Set pre-update index image using digest from tag
70+
ansible.builtin.set_fact:
71+
cifmw_minor_update_pre_update_index_image: >-
72+
quay.io/openstack-k8s-operators/openstack-operator-index@{{ pre_update_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_pre_update_index_image
83+
}}
84+
85+
- name: Override operator build output with pre-update index image for Phase 1
86+
ansible.builtin.set_fact:
87+
cifmw_operator_build_output_pre_update: >-
88+
{{
89+
{
90+
'cifmw_operator_build_output': {
91+
'operators': {
92+
'openstack-operator': {
93+
'image_catalog': cifmw_minor_update_pre_update_index_image
94+
}
95+
}
96+
}
97+
}
98+
}}
99+
100+
- name: Phase 1 - Deploy with pre-update index image using deploy-edpm.yml
101+
block:
102+
- name: Write pre-update operator build output to temporary file
103+
ansible.builtin.copy:
104+
dest: "{{ ansible_user_dir }}/ci-framework-data/artifacts/operator_build_output_pre_update.yml"
105+
content: "{{ cifmw_operator_build_output_pre_update | to_nice_yaml }}"
106+
mode: "0644"
107+
108+
- name: Perform Podified and EDPM deployment on compute nodes with virtual baremetal (pre-update)
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_pre_update.yml"
127+
-e "cifmw_prepare_openstackversion=false"
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
# CI playbook to prepare the environment for OpenStack minor version updates.
3+
# This playbook sets up the cifmw collection and generates the install_yamls_makes
4+
# role on the zuul host (localhost) where ansible-playbook executes.
5+
# This should be run before update.yml to ensure the collection is available.
6+
# This is part of Phase 2 of the baremetal update workflow.
7+
8+
- name: Ensure cifmw collection is available on zuul host
9+
hosts: localhost
10+
gather_facts: false
11+
tasks:
12+
- name: Make symlink of cifmw general collection to Zuul Ansible workdir
13+
ansible.builtin.include_role:
14+
name: cifmw_helpers
15+
tasks_from: symlink_cifmw_collection.yml
16+
vars:
17+
# Use cifmw_project_dir_absolute as fallback if zuul variable is not available
18+
cifmw_helpers_project_dir: >-
19+
{{
20+
(zuul is defined and
21+
zuul.projects is defined and
22+
'github.com/openstack-k8s-operators/ci-framework' in zuul.projects) |
23+
ternary(
24+
ansible_user_dir ~ '/' ~ zuul.projects['github.com/openstack-k8s-operators/ci-framework'].src_dir,
25+
cifmw_project_dir_absolute | default(ansible_user_dir ~ '/src/github.com/openstack-k8s-operators/ci-framework')
26+
)
27+
}}

roles/cifmw_setup/tasks/bootstrap.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
- name: Get latest image for future reference
5656
tags:
5757
- bootstrap
58-
ansible.builtin.import_role:
59-
role: discover_latest_image
58+
ansible.builtin.include_role:
59+
name: discover_latest_image
6060

6161
- name: Create artifacts with custom params
6262
tags:

roles/edpm_prepare/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ cifmw_edpm_prepare_kustomizations: []
3333
# false 'ready' status.
3434
cifmw_edpm_prepare_wait_controplane_status_change_sec: 30
3535
cifmw_edpm_prepare_extra_kustomizations: []
36+
cifmw_prepare_openstackversion: true

roles/edpm_prepare/tasks/kustomize_and_deploy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@
3030

3131
- name: Prepare OpenStackVersion CR
3232
when: >-
33-
(cifmw_update_containers_edpm_image_url is defined and
33+
(cifmw_prepare_openstackversion | bool) and
34+
((cifmw_update_containers_edpm_image_url is defined and
3435
cifmw_update_containers_openstack is defined and
3536
cifmw_update_containers_openstack | bool) or
3637
(cifmw_update_containers_ansibleee_image_url is defined) or
3738
(cifmw_update_containers_openstack is defined and
3839
cifmw_update_containers_openstack | bool) or
3940
(cifmw_update_containers_watcher is defined and
40-
cifmw_update_containers_watcher | bool)
41+
cifmw_update_containers_watcher | bool))
4142
vars:
4243
cifmw_update_containers_metadata: "{{ _ctlplane_name }}"
4344
ansible.builtin.include_role:

roles/install_yamls/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
tags:
146146
- bootstrap
147147
register: cifmw_generate_makes
148-
generate_make_tasks:
148+
cifmw.general.generate_make_tasks:
149149
install_yamls_path: "{{ cifmw_install_yamls_repo }}"
150150
output_directory: "{{ cifmw_install_yamls_tasks_out }}"
151151

roles/update/tasks/init_monitoring.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17+
- name: Set custom cifmw PATH reusable fact if not defined
18+
when:
19+
- cifmw_path is not defined
20+
ansible.builtin.set_fact:
21+
cifmw_path: "{{ ansible_user_dir }}/.crc/bin:{{ ansible_user_dir }}/.crc/bin/oc:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}"
22+
cacheable: true
23+
1724
- name: Ensure update log directory exists.
1825
ansible.builtin.file:
1926
path: "{{ cifmw_update_artifacts_basedir }}"

roles/update/tasks/reboot_computes.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
- name: Set custom cifmw PATH reusable fact if not defined
2+
when:
3+
- cifmw_path is not defined
4+
ansible.builtin.set_fact:
5+
cifmw_path: "{{ ansible_user_dir }}/.crc/bin:{{ ansible_user_dir }}/.crc/bin/oc:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}"
6+
cacheable: true
7+
18
- name: Register storage backend type
29
environment:
310
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"

0 commit comments

Comments
 (0)