Skip to content

Commit bbfd04c

Browse files
committed
Gather VMs facts
Signed-off-by: Daniel Pawlik <dpawlik@redhat.com>
1 parent dfbfe8c commit bbfd04c

File tree

5 files changed

+11
-117
lines changed

5 files changed

+11
-117
lines changed

reproducer.yml

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -84,68 +84,11 @@
8484
ansible.builtin.import_role:
8585
name: reproducer
8686

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-
12987
- name: Finish playbook if prepare environment executed
13088
when:
13189
- cifmw_deploy_reproducer_env | default(false) | bool
13290
ansible.builtin.meta: end_play
13391

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-
14992
- name: Allow traffic from OSP VMs to OSP API (needed for shiftstack)
15093
become: true
15194
when: cifmw_allow_vms_to_reach_osp_api | default (false) | bool

roles/libvirt_manager/tasks/add_vm_to_inventory.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
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 }}"
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 }}"
99

1010
- name: Ensure group section exists
1111
ansible.builtin.lineinfile:

roles/libvirt_manager/tasks/generate_networking_data.yml

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -83,52 +83,6 @@
8383
# END MAC pre-generation management
8484
#
8585
# START generate all IPs using networking_mapper role/module
86-
- name: Inject all VMs in the inventory
87-
when:
88-
- (_cifmw_libvirt_manager_layout.vms[_vm_type].amount | default(1) | int) > 0
89-
vars:
90-
_vm_type: "{{ cifmw_libvirt_manager_all_vms[item.key] | default('none') }}"
91-
_std_group: "{{ (_vm_type == 'crc') | ternary('ocp', _vm_type) }}"
92-
_group: >-
93-
{{
94-
(cifmw_baremetal_hosts is defined and
95-
cifmw_baremetal_hosts[item.key] is defined) |
96-
ternary('baremetal', _std_group)
97-
}}
98-
_ocp_name: >-
99-
{{
100-
item.key | replace('_', '-') |
101-
replace('ocp-', '')
102-
}}
103-
_hostname: >-
104-
{{
105-
(item.key is match('^ocp.*')) |
106-
ternary(_ocp_name, item.key) |
107-
replace('_', '-')
108-
}}
109-
_ssh_user: >-
110-
{{
111-
_cifmw_libvirt_manager_layout.vms[_vm_type].admin_user |
112-
default(_cifmw_libvirt_manager_layout.vms[_vm_type].user) |
113-
default('zuul')
114-
}}
115-
_add_ansible_host: >-
116-
{{
117-
_cifmw_libvirt_manager_layout.vms[_vm_type].manage | default(true) and
118-
_cifmw_libvirt_manager_layout.vms[_vm_type].disk_file_name | default(_vm_type is not none) != 'blank'
119-
}}
120-
_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 }}"
127-
loop: "{{ cifmw_libvirt_manager_mac_map | dict2items }}"
128-
loop_control:
129-
label: "Adding {{ item.key }} to {{ _group }}s"
130-
131-
## daniel
13286
- name: Inject all VMs in the inventory
13387
when:
13488
- (_cifmw_libvirt_manager_layout.vms[_vm_type].amount | default(1) | int) > 0
@@ -186,7 +140,6 @@
186140
ansible-inventory
187141
-i {{ cifmw_libvirt_manager_tmp_inv_file }}
188142
-y --list > {{ cifmw_libvirt_manager_dst_inv_file }}
189-
###
190143
191144
- name: Generate all IPs based on MAC and networks
192145
vars:

roles/networking_mapper/tasks/load_env_definition.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,3 @@
3333
from_yaml
3434
}}
3535
cacheable: true
36-
37-
- name: Daniel - print current cifmw_networking_env_definition if defined
38-
when: "cifmw_networking_env_definition is defined"
39-
ansible.builtin.debug:
40-
msg: |
41-
{{ cifmw_networking_env_definition }}

roles/reproducer/tasks/configure_controller.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,10 @@
474474
cifmw_networking_mapper_network_name: >-
475475
{{ _cifmw_libvirt_manager_layout.vms.controller.nets.1 }}
476476
cifmw_networking_mapper_basedir: "{{ cifmw_reproducer_controller_basedir }}"
477+
# NOTE(dpawlik): Without gathering facts here, on executing reproducer
478+
# playbook via Zironic or locally, the /etc/ci/env/networking-environment-definition.yml
479+
# in later state will not contain: "hostname" and "interface_name" keys,
480+
# which would fail on generating network-values using ci_gen_kustomize_values.
477481
cifmw_networking_mapper_gather_facts: true
478482
ansible.builtin.import_role:
479483
name: networking_mapper

0 commit comments

Comments
 (0)