Skip to content

Commit 623b8ca

Browse files
committed
Prepare cifmw to run with Zironic
The Zironic tool would pre-deploy OCP cluster before CI job will "pick" the baremetal host. Signed-off-by: Daniel Pawlik <[email protected]>
1 parent 052ccea commit 623b8ca

File tree

7 files changed

+191
-68
lines changed

7 files changed

+191
-68
lines changed

reproducer.yml

Lines changed: 126 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,69 @@
55
- name: Reproducer prepare play
66
hosts: "{{ cifmw_target_host | default('localhost') }}"
77
gather_facts: true
8-
pre_tasks:
9-
- name: Inherit from parent scenarios if needed
10-
ansible.builtin.include_tasks:
11-
file: "ci/playbooks/tasks/inherit_parent_scenario.yml"
12-
13-
- name: Include common architecture parameter file
8+
tasks:
9+
- name: Run tasks - reproducer prepare
1410
when:
15-
- cifmw_architecture_scenario is defined
16-
- cifmw_architecture_scenario | length > 0
17-
ansible.builtin.include_vars:
18-
file: "scenarios/reproducers/va-common.yml"
11+
- cifmw_deploy_reproducer_env | default(true) | bool
12+
block:
13+
- name: Inherit from parent scenarios if needed
14+
ansible.builtin.include_tasks:
15+
file: "ci/playbooks/tasks/inherit_parent_scenario.yml"
1916

20-
- name: Run reproducer validations
21-
ansible.builtin.import_role:
22-
name: reproducer
23-
tasks_from: validations.yml
17+
- name: Include common architecture parameter file
18+
when:
19+
- cifmw_architecture_scenario is defined
20+
- cifmw_architecture_scenario | length > 0
21+
ansible.builtin.include_vars:
22+
file: "scenarios/reproducers/va-common.yml"
2423

25-
- name: Gather OS facts
26-
ansible.builtin.setup:
27-
gather_subset:
28-
- "!all"
29-
- "!min"
30-
- "distribution"
24+
- name: Run reproducer validations
25+
ansible.builtin.import_role:
26+
name: reproducer
27+
tasks_from: validations.yml
3128

32-
- name: Tweak dnf configuration
33-
become: true
34-
community.general.ini_file:
35-
no_extra_spaces: true
36-
option: "{{ config.option }}"
37-
path: "/etc/dnf/dnf.conf"
38-
section: "{{ config.section | default('main') }}"
39-
state: "{{ config.state | default(omit) }}"
40-
value: "{{ config.value | default(omit) }}"
41-
mode: "0644"
42-
loop: "{{ cifmw_reproducer_dnf_tweaks }}"
43-
loop_control:
44-
label: "{{ config.option }}"
45-
loop_var: 'config'
46-
47-
- name: Install custom CA if needed
48-
ansible.builtin.import_role:
49-
name: install_ca
29+
- name: Gather OS facts
30+
ansible.builtin.setup:
31+
gather_subset:
32+
- "!all"
33+
- "!min"
34+
- "distribution"
5035

51-
- name: Setup repositories via rhos-release if needed
52-
tags:
53-
- packages
54-
when:
55-
- ansible_facts['distribution'] == 'RedHat'
56-
- cifmw_reproducer_hp_rhos_release | bool
57-
vars:
58-
cifmw_repo_setup_output: /etc/yum.repos.d
59-
cifmw_repo_setup_rhos_release_args: "rhel"
60-
ansible.builtin.import_role:
61-
name: repo_setup
62-
tasks_from: rhos_release.yml
36+
- name: Tweak dnf configuration
37+
become: true
38+
community.general.ini_file:
39+
no_extra_spaces: true
40+
option: "{{ config.option }}"
41+
path: "/etc/dnf/dnf.conf"
42+
section: "{{ config.section | default('main') }}"
43+
state: "{{ config.state | default(omit) }}"
44+
value: "{{ config.value | default(omit) }}"
45+
mode: "0644"
46+
loop: "{{ cifmw_reproducer_dnf_tweaks }}"
47+
loop_control:
48+
label: "{{ config.option }}"
49+
loop_var: 'config'
50+
51+
- name: Install custom CA if needed
52+
ansible.builtin.import_role:
53+
name: install_ca
6354

64-
roles:
65-
- role: ci_setup
55+
- name: Setup repositories via rhos-release if needed
56+
tags:
57+
- packages
58+
when:
59+
- ansible_facts['distribution'] == 'RedHat'
60+
- cifmw_reproducer_hp_rhos_release | bool
61+
vars:
62+
cifmw_repo_setup_output: /etc/yum.repos.d
63+
cifmw_repo_setup_rhos_release_args: "rhel"
64+
ansible.builtin.import_role:
65+
name: repo_setup
66+
tasks_from: rhos_release.yml
67+
68+
- name: Run ci_setup
69+
ansible.builtin.import_role:
70+
name: ci_setup
6671

6772
- name: Prepare switches
6873
vars:
@@ -72,9 +77,75 @@
7277
- name: Reproducer run
7378
hosts: "{{ cifmw_target_host | default('localhost') }}"
7479
gather_facts: false
75-
roles:
76-
- role: reproducer
77-
post_tasks:
80+
tasks:
81+
- name: Run reproducer role
82+
when:
83+
- cifmw_deploy_reproducer_env | default(true) | bool
84+
ansible.builtin.import_role:
85+
name: reproducer
86+
87+
#######
88+
- name: Get vars
89+
copy:
90+
content: |
91+
{{ vars }}
92+
dest: "{{ ansible_user_dir }}/daniel-vars"
93+
ignore_errors: true
94+
no_log: true
95+
96+
- name: Get environment
97+
copy:
98+
content: |
99+
{{ environment }}
100+
dest: "{{ ansible_user_dir }}/daniel-environment"
101+
ignore_errors: true
102+
no_log: true
103+
104+
- name: Get group_names
105+
copy:
106+
content: |
107+
{{ group_names }}
108+
dest: "{{ ansible_user_dir }}/daniel-group_names"
109+
ignore_errors: true
110+
no_log: true
111+
112+
- name: Get groups
113+
copy:
114+
content: |
115+
{{ groups }}
116+
dest: "{{ ansible_user_dir }}/daniel-groups"
117+
ignore_errors: true
118+
no_log: true
119+
120+
- name: Get hostvars
121+
copy:
122+
content: |
123+
{{ hostvars }}
124+
dest: "{{ ansible_user_dir }}/daniel-hostvars"
125+
ignore_errors: true
126+
no_log: true
127+
128+
129+
- name: Finish playbook if prepare environment executed
130+
when:
131+
- cifmw_deploy_reproducer_env | default(false) | bool
132+
ansible.builtin.meta: end_play
133+
134+
# Temporary
135+
- name: Check if libvirt inventory file exists
136+
ansible.builtin.stat:
137+
path: "{{ ansible_user_dir }}/libvirt_inventory.yaml"
138+
register: _libvirt_inventory
139+
140+
- name: Read inventory file and add it using add_host module
141+
when: _libvirt_inventory.stat.exists
142+
vars:
143+
include_inventory_file: "{{ ansible_user_dir }}/libvirt_inventory.yaml"
144+
ansible.builtin.include_role:
145+
name: cifmw_helpers
146+
tasks_from: inventory_file.yml
147+
#
148+
78149
- name: Allow traffic from OSP VMs to OSP API (needed for shiftstack)
79150
become: true
80151
when: cifmw_allow_vms_to_reach_osp_api | default (false) | bool

roles/devscripts/tasks/131_packages.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,3 @@
2828
ansible.builtin.import_role:
2929
name: ci_setup
3030
tasks_from: epel.yml
31-
32-
- name: Ensure conflicting package does not exist.
33-
become: true
34-
ansible.builtin.package:
35-
name: "ansible-core"
36-
state: absent

roles/dnsmasq/handlers/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
- _dnsmasq.msg is defined
2525
- _dnsmasq.msg is not
2626
match('Could not find the requested service cifmw-dnsmasq.service')
27+
retries: 5
28+
delay: 15
29+
until: _dnsmasq is succeeded
2730

2831
- name: Reload dnsmasq
2932
become: true

roles/libvirt_manager/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,7 @@ cifmw_libvirt_manager_extra_network_configuration: {}
8989

9090
cifmw_libvirt_manager_vm_users: []
9191
cifmw_libvirt_manager_radvd_networks: []
92+
93+
94+
cifmw_libvirt_manager_tmp_inv_file: "{{ ansible_user_dir }}/libvirt_inventory.ini"
95+
cifmw_libvirt_manager_dst_inv_file: "{{ ansible_user_dir }}/libvirt_inventory.yaml"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
- name: Add host to runtime inventory
3+
ansible.builtin.add_host:
4+
name: "{{ _full_host_name }}"
5+
groups: "{{ _group }}s"
6+
ansible_ssh_user: "{{ _ssh_user }}"
7+
ansible_host: "{{ _add_ansible_host | ternary(_ansible_host, omit) }}"
8+
vm_type: "{{ _group }}"
9+
10+
- name: Ensure group section exists
11+
ansible.builtin.lineinfile:
12+
path: "{{ cifmw_libvirt_manager_tmp_inv_file }}"
13+
create: true
14+
line: "[{{ _group }}s]"
15+
regexp: "^\\[{{ _group }}s\\]$"
16+
state: present
17+
18+
- name: Append host under proper group
19+
ansible.builtin.lineinfile:
20+
path: "{{ cifmw_libvirt_manager_tmp_inv_file }}"
21+
insertafter: "^\\[{{ _group }}s\\]$"
22+
line: "{{ _ini_line }}"
23+
regexp: "^{{ _full_host_name | regex_escape() }} "

roles/libvirt_manager/tasks/generate_networking_data.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,29 @@
118118
_cifmw_libvirt_manager_layout.vms[_vm_type].disk_file_name | default(_vm_type is not none) != 'blank'
119119
}}
120120
_ansible_host: "{{ _hostname }}.{{ inventory_hostname }}"
121-
ansible.builtin.add_host:
122-
name: "{{ item.key | replace('_', '-') }}"
123-
groups: "{{ _group }}s"
124-
ansible_ssh_user: "{{ _ssh_user }}"
125-
ansible_host: "{{ _add_ansible_host | ternary(_ansible_host, omit) }}"
126-
vm_type: "{{ _group }}"
121+
_full_host_name: "{{ item.key | replace('_', '-') }}"
122+
_ini_line: >-
123+
{{ _full_host_name }}
124+
{% if _add_ansible_host %} ansible_host={{ _ansible_host }}{% endif %}
125+
ansible_user={{ _ssh_user }}
126+
vm_type={{ _group }}
127+
ansible.builtin.include_tasks: add_vm_to_inventory.yml
127128
loop: "{{ cifmw_libvirt_manager_mac_map | dict2items }}"
128129
loop_control:
129130
label: "Adding {{ item.key }} to {{ _group }}s"
130131

132+
- name: Check if ini inventory file exists
133+
ansible.builtin.stat:
134+
path: "{{ cifmw_libvirt_manager_tmp_inv_file }}"
135+
register: _libvirt_inv_file
136+
137+
- name: Convert ini inventory file into yaml
138+
when: _libvirt_inv_file.stat.exists
139+
ansible.builtin.shell: >
140+
ansible-inventory
141+
-i {{ cifmw_libvirt_manager_tmp_inv_file }}
142+
-y --list > {{ cifmw_libvirt_manager_dst_inv_file }}
143+
131144
- name: Generate all IPs based on MAC and networks
132145
vars:
133146
cifmw_networking_mapper_ifaces_info: >-

roles/reproducer/tasks/push_code.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
---
2+
# FIXME: Normally that part should not be needed, but...
3+
# if all "required" projects in Zuul var would not be available,
4+
# later we will have an error:
5+
#
6+
# TASK [repo_setup : Make sure git-core package is installed] ********************
7+
# fatal: [hypervisor -> controller-0(controller-0.hypervisor)]: FAILED! =>
8+
# fact that ''no_log: true'' was specified
9+
#
10+
# OR
11+
#
12+
# TASK [repo_setup : Make sure git-core package is installed] ********************
13+
# ok: [hypervisor -> controller-0(controller-0.hypervisor)]
14+
# TASK [repo_setup : Get repo-setup repository] **********************************
15+
# fatal: [hypervisor -> controller-0(controller-0.hypervisor)]: FAILED! =>
16+
# fact that ''no_log: true'' was specified
17+
#
218
- name: Sync zuul content if available
319
when:
420
- (zuul is defined) or (zuul_vars.zuul is defined)
@@ -62,7 +78,6 @@
6278
cmd: "git -c 'user.name=zuul' -c '[email protected]' pull --rebase origin {{ refspec | regex_replace(':.*', '') }}"
6379
loop: "{{ ansible_failed_result['results'] }}"
6480

65-
6681
- name: Fetch zuul.projects repositories for dependencies
6782
when:
6883
- "repo.key not in (_depends_on_patches | map(attribute='project.canonical_name'))"

0 commit comments

Comments
 (0)