|
83 | 83 | # END MAC pre-generation management |
84 | 84 | # |
85 | 85 | # 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 | +## |
86 | 132 | - name: Inject all VMs in the inventory |
87 | 133 | when: |
88 | 134 | - (_cifmw_libvirt_manager_layout.vms[_vm_type].amount | default(1) | int) > 0 |
|
141 | 187 | -i {{ cifmw_libvirt_manager_tmp_inv_file }} |
142 | 188 | -y --list > {{ cifmw_libvirt_manager_dst_inv_file }} |
143 | 189 |
|
| 190 | +
|
144 | 191 | - name: Generate all IPs based on MAC and networks |
145 | 192 | vars: |
146 | 193 | cifmw_networking_mapper_ifaces_info: >- |
|
0 commit comments