Skip to content

Commit 7c6e830

Browse files
committed
[reproducer] Sync src dir when controller available and using ZIronic
Keep support for legacy workflow where controller host is created and actions are done not on hypervisor directly, but on controller. Signed-off-by: Daniel Pawlik <dpawlik@redhat.com>
1 parent 8aadd02 commit 7c6e830

4 files changed

Lines changed: 69 additions & 9 deletions

File tree

reproducer.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,22 @@
108108
name: firewalld
109109
state: restarted
110110

111+
# NOTE(dpawlik): Keep support for legacy workflow where
112+
# controller host is created and actions are done not on
113+
# hypervisor directly, but on controller.
111114
# NOTE(dpawlik): Synchronize current Zuul repositories stored in $HOME/src
112115
# to controller-0 to make sure all projects are in state as they should.
113-
- name: Synchronize src dir with controller-0
116+
- name: Set hypervisor name if not defined
117+
when: hypervisor is not defined
118+
ansible.builtin.set_fact:
119+
hypervisor: "{{ ansible_fqdn }}"
120+
121+
- name: Synchronize src dir
114122
when:
115123
- not cifmw_deploy_reproducer_env | default(true) | bool
116-
vars:
117-
sync_dir: "{{ ansible_user_dir }}/src"
118-
ansible.posix.synchronize:
119-
src: "{{ sync_dir }}/"
120-
dest: "zuul@controller-0:{{ sync_dir }}"
121-
archive: true
122-
recursive: true
124+
ansible.builtin.include_role:
125+
name: reproducer
126+
tasks_from: sync_src_dir.yml
123127

124128
# NOTE(dpawlik): After calling reproducer role using ZIronic tool,
125129
# when the bootstrap phase has been completed, it generates a file
@@ -133,6 +137,7 @@
133137
ansible.builtin.include_role:
134138
name: reproducer
135139
tasks_from: overwrite_zuul_vars.yml
140+
136141
- name: Run deployment if instructed to
137142
when:
138143
- cifmw_deploy_architecture | default(false) | bool

roles/cifmw_setup/tasks/bootstrap.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
role: discover_latest_image
6060

6161
- name: Create artifacts with custom params
62+
when:
63+
- cifmw_deploy_reproducer_env | default(true) | bool
6264
tags:
6365
- always
6466
ansible.builtin.copy:

roles/reproducer/tasks/overwrite_zuul_vars.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
path: "{{ ansible_user_dir }}/configs/zuul_vars.yaml"
1414
register: _current_zuul_vars
1515

16-
- name: Overwrite reproducer-variables.yml when ZIronic used
16+
- name: Overwrite reproducer-variables.yml when PreMetal used
1717
when: _current_zuul_vars.stat.exists
1818
vars:
1919
temp_reproducer_var_path: /tmp/reproducer-variables.yml
@@ -62,3 +62,11 @@
6262
backup: true
6363
no_log: "{{ cifmw_nolog | default(true) | bool }}"
6464
delegate_to: controller-0
65+
66+
- name: Overwrite custom-params.yml
67+
ansible.builtin.copy:
68+
content: "{{ merged_reproducer_slurp.content | b64decode }}"
69+
dest: "{{ cifmw_basedir }}/artifacts/parameters/custom-params.yml"
70+
mode: "0664"
71+
no_log: "{{ cifmw_nolog | default(true) | bool }}"
72+
delegate_to: controller-0
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
# NOTE(dpawlik): Synchronize data when PreMetal provision+bootstrap the
3+
# hypervisor AND Zuul job uses PreMetal flavor which is executing
4+
# job directly on hypervisor. When job starts, src and secrets dir are "recreated"
5+
# by zuul-executor with current job data. Sync the data with
6+
# controller-0 which is executing nested Ansible.
7+
- name: Synchronize hypervisor secrets dir with controller-0
8+
vars:
9+
sync_dir: "{{ ansible_user_dir }}/{{ subdir }}"
10+
ansible.posix.synchronize:
11+
src: "{{ sync_dir }}/"
12+
dest: "zuul@controller-0:{{ sync_dir }}"
13+
archive: true
14+
recursive: true
15+
no_log: "{{ cifmw_nolog | default(true) | bool }}"
16+
loop:
17+
- secrets
18+
- src
19+
loop_control:
20+
loop_var: subdir
21+
22+
# NOTE(dpawlik): Synchronize data when PreMetal provision+bootstrap the
23+
# hypervisor BUT legacy workflow is used (spawning controller VM
24+
# which is executing all other playbooks). When job starts, all
25+
# data like secrets, src dir etc. is stored on controller VM, but because
26+
# later tasks are using nested ansible execution, then all playbooks needs
27+
# to be up-to-date.
28+
# That case would be mostly used by developers. Synchronize module
29+
# would ignore if sync would happen to the same host. No need to synchronize
30+
# with controller-0 again, due tasks above would do that.
31+
- name: Synchronize controller VM configs, secrets and src dir with hypervisor
32+
vars:
33+
sync_dir: "{{ ansible_user_dir }}/{{ subdir }}"
34+
ansible.posix.synchronize:
35+
src: "{{ sync_dir }}/"
36+
dest: "zuul@{{ hypervisor }}:{{ sync_dir }}"
37+
archive: true
38+
recursive: true
39+
no_log: "{{ cifmw_nolog | default(true) | bool }}"
40+
loop:
41+
- configs
42+
- secrets
43+
- src
44+
loop_control:
45+
loop_var: subdir

0 commit comments

Comments
 (0)