Skip to content
Draft
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
13 changes: 13 additions & 0 deletions reproducer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@
name: firewalld
state: restarted

# NOTE(dpawlik): After calling reproducer role using ZIronic tool,
# when the bootstrap phase has been completed, it generates a file
# "reproducer-variables.yml" that contains all variables done in the
# CI job. The problem here is, that "testing" phase might have other
# variables than what was in the bootstrap phase. It means, that
# we need to overwrite the variables with current CI job vars.
- name: Overwrite reproducer-variables.yml when ZIronic bootstrap
when:
- not cifmw_deploy_reproducer_env | default(true) | bool
ansible.builtin.include_role:
name: reproducer
tasks_from: overwrite_zuul_vars.yml

- name: Run deployment if instructed to
when:
- cifmw_deploy_architecture | default(false) | bool
Expand Down
59 changes: 59 additions & 0 deletions roles/reproducer/tasks/overwrite_zuul_vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# FIXME(dpawlik): Most variables are available,
# but we can not parse variables that were not dumped into
# reproducer-variables.yml or they are unknown.
# Get desired variables necessary during the bootstrap, like:
# cifmw_discovered_image_url even when it is not needed, because
# nodes that require that var are already deployed.
# Find a way to parse vars with undefined vars with combine.
- name: Get latest image for future reference
ansible.builtin.import_role:
role: discover_latest_image

# Based on: roles/cifmw_setup/tasks/bootstrap.yml
- name: Get customized parameters
ansible.builtin.set_fact:
zuul_job_overwrite_vars: >-
{{
hostvars[cifmw_target_host | default('hypervisor')] |
dict2items |
selectattr("key", "match",
"^(cifmw|pre|post)_(?!install_yamls|openshift_token|openshift_login|openshift_kubeconfig).*") |
list | items2dict
}}
no_log: "{{ cifmw_nolog | default(true) | bool }}"

- name: Overwrite reproducer-variables.yml when ZIronic used
block:
# NOTE: To avoid situation, that reproducer-variables.yml contains
# undefined variable, because not always all variables can be resolved
# (sometimes vars are defined in scenarios in later stage), it might
# fail because of that. Better is to set as a fact, and dump to a file,
# especially that the reproducer-variables.yml is taken as an argument
# var when calling nested ansible.
- name: Fetch reproducer-variables.yml to hypervisor
ansible.builtin.fetch:
src: "{{ cifmw_basedir }}/parameters/reproducer-variables.yml"
dest: /tmp/reproducer-variables.yml
flat: true
delegate_to: controller-0

- name: Read reproducer-variables.yml
ansible.builtin.slurp:
src: /tmp/reproducer-variables.yml
register: reproducer_original
no_log: "{{ cifmw_nolog | default(true) | bool }}"

- name: Deep merge and write back
ansible.builtin.copy:
content: >-
{{
(reproducer_original.content | b64decode | from_yaml)
| combine(zuul_job_overwrite_vars, recursive=true)
| to_nice_yaml
}}
dest: "{{ cifmw_basedir }}/parameters/reproducer-variables.yml"
mode: '0644'
backup: true
no_log: "{{ cifmw_nolog | default(true) | bool }}"
delegate_to: controller-0
Loading