Skip to content

Commit 94a2d45

Browse files
committed
[reproducer] Refresh premetal config vars from resolved hostvars
In premetal deployments, config variables updated between bootstrap and pickup were not reflected in reproducer-variables.yml. Overwrite it at pickup time by dumping the hypervisor's filtered hostvars using the same filter chain as configure_bm_ocp_controller.yml. Generated-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Michael Burke <michburk@redhat.com>
1 parent fc87553 commit 94a2d45

1 file changed

Lines changed: 37 additions & 52 deletions

File tree

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,57 @@
11
---
2-
# NOTE(dpawlik): Earlier, our idea was to dump vars as
3-
# it is roles/cifmw_setup/tasks/bootstrap.yml and read it,
4-
# then dump it and replace reproducer-variables.yml.
5-
# Normally it make sense, but since we dump zuul_vars in
6-
# run.yml, we don't need to make such combination, which is
7-
# more safe - on making host variable dump, some variables
8-
# might not be defined, so later we can have an issue like:
9-
# 'cifmw_discovered_image_url' is undefined.
2+
# Update reproducer-variables.yml on controller-0 with the current
3+
# hypervisor hostvars. At premetal pickup time the hypervisor has
4+
# all config files loaded as extra vars (via run-uni-reproducer.sh),
5+
# so hostvars contains every variable fully resolved -- no raw Jinja2.
6+
#
7+
# This is a straight overwrite using the same filter chain as the
8+
# bootstrap in configure_bm_ocp_controller.yml. The hypervisor's
9+
# pickup-time hostvars are a superset of what was dumped at bootstrap
10+
# (same config files plus any updates), so no merge is needed.
1011

1112
- name: Check if zuul_vars.yaml file is available
1213
ansible.builtin.stat:
1314
path: "{{ ansible_user_dir }}/configs/zuul_vars.yaml"
1415
register: _current_zuul_vars
1516

16-
- name: Overwrite reproducer-variables.yml when PreMetal used
17+
- name: Update reproducer-variables.yml from resolved hostvars
1718
when: _current_zuul_vars.stat.exists
1819
vars:
19-
temp_reproducer_var_path: /tmp/reproducer-variables.yml
20-
temp_merged_reproducer_var_path: /tmp/merged-reproducer-variables.yml
20+
_filtered_vars: >-
21+
{{
22+
hostvars[inventory_hostname] | default({}) |
23+
dict2items |
24+
selectattr('key', 'match',
25+
'^(pre|post|cifmw)_(?!install_yamls|devscripts).*') |
26+
rejectattr('key', 'equalto', 'cifmw_target_host') |
27+
rejectattr('key', 'equalto', 'cifmw_basedir') |
28+
rejectattr('key', 'equalto', 'cifmw_path') |
29+
rejectattr('key', 'equalto', 'cifmw_extras') |
30+
rejectattr('key', 'equalto', 'cifmw_openshift_kubeconfig') |
31+
rejectattr('key', 'equalto', 'cifmw_openshift_token') |
32+
rejectattr('key', 'equalto', 'cifmw_networking_env_definition') |
33+
rejectattr('key', 'match', '^cifmw_use_(?!lvms).*') |
34+
rejectattr('key', 'match', '^cifmw_reproducer.*') |
35+
rejectattr('key', 'match', '^cifmw_rhol.*') |
36+
rejectattr('key', 'match', '^cifmw_discover.*') |
37+
rejectattr('key', 'match', '^cifmw_libvirt_manager.*') |
38+
rejectattr('key', 'match', '^cifmw_manage_secrets_(pullsecret|citoken).*') |
39+
items2dict
40+
}}
2141
block:
22-
- name: Slurp reproducer-variables.yml to hypervisor
23-
ansible.builtin.slurp:
24-
src: "{{ cifmw_basedir }}/parameters/reproducer-variables.yml"
25-
register: reproducer_original
26-
delegate_to: controller-0
27-
no_log: "{{ cifmw_nolog | default(true) | bool }}"
28-
29-
- name: Create temp file reproducer-variables.yml on hypervisor
42+
- name: Write reproducer-variables.yml to controller-0
3043
ansible.builtin.copy:
31-
content: "{{ reproducer_original.content | b64decode }}"
32-
dest: "{{ temp_reproducer_var_path }}"
33-
mode: "0664"
34-
no_log: "{{ cifmw_nolog | default(true) | bool }}"
35-
36-
- name: Copy merge yamls script
37-
become: true
38-
ansible.builtin.copy:
39-
src: merge_yaml_override.py
40-
dest: /usr/local/bin/merge_yaml_override
41-
mode: "0755"
42-
43-
- name: Execute merge script
44-
ansible.builtin.shell: >
45-
python3 /usr/local/bin/merge_yaml_override
46-
{{ temp_reproducer_var_path }}
47-
{{ ansible_user_dir }}/configs/zuul_vars.yaml >
48-
{{ temp_merged_reproducer_var_path }}
49-
no_log: "{{ cifmw_nolog | default(true) | bool }}"
50-
51-
- name: Slurp merged reproducer-variables.yml from hypervisor
52-
ansible.builtin.slurp:
53-
src: "{{ temp_merged_reproducer_var_path }}"
54-
register: merged_reproducer_slurp
55-
no_log: "{{ cifmw_nolog | default(true) | bool }}"
56-
57-
- name: Write back merged reproducer-variables.yml
58-
ansible.builtin.copy:
59-
content: "{{ merged_reproducer_slurp.content | b64decode }}"
44+
content: "{{ _filtered_vars | to_nice_yaml }}"
6045
dest: "{{ cifmw_basedir }}/parameters/reproducer-variables.yml"
6146
mode: "0664"
6247
backup: true
63-
no_log: "{{ cifmw_nolog | default(true) | bool }}"
6448
delegate_to: controller-0
49+
no_log: "{{ cifmw_nolog | default(true) | bool }}"
6550

66-
- name: Overwrite custom-params.yml
51+
- name: Write custom-params.yml to controller-0
6752
ansible.builtin.copy:
68-
content: "{{ merged_reproducer_slurp.content | b64decode }}"
53+
content: "{{ _filtered_vars | to_nice_yaml }}"
6954
dest: "{{ cifmw_basedir }}/artifacts/parameters/custom-params.yml"
7055
mode: "0664"
71-
no_log: "{{ cifmw_nolog | default(true) | bool }}"
7256
delegate_to: controller-0
57+
no_log: "{{ cifmw_nolog | default(true) | bool }}"

0 commit comments

Comments
 (0)