Skip to content
Merged
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
19 changes: 4 additions & 15 deletions ansible/roles/bastion-network/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@
when:
- enable_bond | default(false)
block:
- name: Set bastion bond interface names from hardware mapping
set_fact:
bastion_bond0_interface1: "{{ hw_nic_name[lab][machine_type][bond0_port1|int] }}"
bastion_bond0_interface2: "{{ hw_nic_name[lab][machine_type][bond0_port2|int] }}"
when:
- lab in hw_nic_name
- machine_type in hw_nic_name[lab]
- hw_nic_name[lab][machine_type] | length > (bond0_port2|int)

- name: Remove existing connections for bond slave interfaces
nmcli:
Expand All @@ -106,18 +98,16 @@
loop:
- "{{ bastion_bond0_interface1 }}"
- "{{ bastion_bond0_interface2 }}"
ignore_errors: true

- name: Create bond0 connection for bastion
nmcli:
type: bond
conn_name: bond0
ifname: bond0
ip4: "{{ bastion_controlplane_ip }}/{{ controlplane_network_prefix }}"
mode: 802.3ad
miimon: 100
state: present
bond:
mode: 802.3ad
miimon: 100
when: bastion_controlplane_ip | ansible.utils.ipv4

- name: Create bond0 connection for bastion (ipv6)
Expand All @@ -126,10 +116,9 @@
conn_name: bond0
ifname: bond0
ip6: "{{ bastion_controlplane_ip }}/{{ controlplane_network_prefix }}"
mode: 802.3ad
miimon: 100
state: present
bond:
mode: 802.3ad
miimon: 100
when: bastion_controlplane_ip | ansible.utils.ipv6

- name: Add first interface as bond slave
Expand Down
4 changes: 2 additions & 2 deletions ansible/roles/create-inventory/defaults/main/networks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ bond0_port2: 2
# The assisted-installer doesn't need exact nic names for the private bond. These names are used
# as representatives for the actual nic names, the actual nics are determined by the mac addresses
private_bond_interfaces:
- eth0
- eth1
- eth0
- eth1
59 changes: 42 additions & 17 deletions ansible/roles/create-inventory/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@
- lab in hw_nic_name
- machine_type in hw_nic_name[lab]

- name: Auto-configure bastion bond interfaces (only when bonding is enabled)
set_fact:
bastion_bond0_interface1: "{{ hw_nic_name[lab][machine_type][bond0_port1|int] }}"
bastion_bond0_interface2: "{{ hw_nic_name[lab][machine_type][bond0_port2|int] }}"
when:
- enable_bond | default(false)
- lab in hw_nic_name
- machine_type in hw_nic_name[lab]
- hw_nic_name[lab][machine_type] | length > (bond0_port2|int)

- name: Bond configuration for scale/performance labs
when: (lab in rh_labs) and enable_bond | default(false) and not (public_vlan | default(false))
block:
Expand Down Expand Up @@ -198,15 +208,18 @@
block:
- name: MNO - Set controlplane0 bond mac addresses
set_fact:
controlplane0_bond0_macs: "{{ (controlplane0_foreman_data.json.interfaces | selectattr('name', 'eq', bond0_interface1) | first).mac }},{{ (controlplane0_foreman_data.json.interfaces | selectattr('name', 'eq', bond0_interface2) | first).mac }}"
controlplane0_bond0_macs: >-
{{ ocpinventory.json.nodes[1].mac[bond0_port1|int - 1] ~ ',' ~ ocpinventory.json.nodes[1].mac[bond0_port2|int - 1] }}

- name: MNO - Set controlplane1 bond mac addresses
set_fact:
controlplane1_bond0_macs: "{{ (controlplane1_foreman_data.json.interfaces | selectattr('name', 'eq', bond0_interface1) | first).mac }},{{ (controlplane1_foreman_data.json.interfaces | selectattr('name', 'eq', bond0_interface2) | first).mac }}"
controlplane1_bond0_macs: >-
{{ ocpinventory.json.nodes[2].mac[bond0_port1|int - 1] ~ ',' ~ ocpinventory.json.nodes[2].mac[bond0_port2|int - 1] }}

- name: MNO - Set controlplane2 bond mac addresses
set_fact:
controlplane2_bond0_macs: "{{ (controlplane2_foreman_data.json.interfaces | selectattr('name', 'eq', bond0_interface1) | first).mac }},{{ (controlplane2_foreman_data.json.interfaces | selectattr('name', 'eq', bond0_interface2) | first).mac }}"
controlplane2_bond0_macs: >-
{{ ocpinventory.json.nodes[3].mac[bond0_port1|int - 1] ~ ',' ~ ocpinventory.json.nodes[3].mac[bond0_port2|int - 1] }}

- name: MNO - Set max number of nodes
set_fact:
Expand Down Expand Up @@ -242,16 +255,16 @@
set_fact:
ocpinventory_worker_nodes: >-
{{
ocpinventory_worker_nodes | zip(mno_foreman_data.results) |
map('combine') |
map('combine', {
'bond0_macs': ((item.1.json.interfaces | selectattr('name', 'eq', bond0_interface1) | first).mac + ',' + (item.1.json.interfaces | selectattr('name', 'eq', bond0_interface2) | first).mac)
}) |
list
ocpinventory_worker_nodes[:idx] +
[ocpinventory_worker_nodes[idx] | combine({
'bond0_macs': (item.mac[bond0_port1|int - 1] + ',' + item.mac[bond0_port2|int - 1])
})] +
ocpinventory_worker_nodes[idx + 1:]
}}
loop: "{{ ocpinventory_worker_nodes | zip(mno_foreman_data.results) | list }}"
loop: "{{ ocpinventory_worker_nodes }}"
loop_control:
loop_var: item
index_var: idx

- name: Single Node OpenShift cluster type tasks
when: cluster_type == "sno"
Expand Down Expand Up @@ -296,21 +309,33 @@
when: cluster_type == "sno" and ocpinventory_worker_nodes|length > 0
register: sno_worker_foreman_data

- name: SNO - Auto-configure bond interface names from hardware mapping (when bonding is enabled)
set_fact:
bond0_interface1: "{{ hw_nic_name[lab][machine_type][bond0_port1|int] }}"
bond0_interface2: "{{ hw_nic_name[lab][machine_type][bond0_port2|int] }}"
when:
- enable_bond | default(false) and not (public_vlan | default(false))
- lab in hw_nic_name
- machine_type in hw_nic_name[lab]
- hw_nic_name[lab][machine_type] | length > (bond0_port2|int)



- name: SNO - Add bond MAC addresses to SNO nodes (when bonding is enabled)
when: enable_bond | default(false) and not (public_vlan | default(false))
set_fact:
ocpinventory_sno_nodes: >-
{{
ocpinventory_sno_nodes | zip(sno_foreman_data.results) |
map('combine') |
map('combine', {
'bond0_macs': ((item.1.json.interfaces | selectattr('name', 'eq', bond0_interface1) | first).mac + ',' + (item.1.json.interfaces | selectattr('name', 'eq', bond0_interface2) | first).mac)
}) |
list
ocpinventory_sno_nodes[:idx] +
[ocpinventory_sno_nodes[idx] | combine({
'bond0_macs': (item.mac[bond0_port1|int - 1 ] + ',' + item.mac[bond0_port2|int - 1])
})] +
ocpinventory_sno_nodes[idx + 1:]
}}
loop: "{{ ocpinventory_sno_nodes | zip(sno_foreman_data.results) | list }}"
loop: "{{ ocpinventory_sno_nodes }}"
loop_control:
loop_var: item
index_var: idx

- name: set json query fact
set_fact:
Expand Down
4 changes: 4 additions & 0 deletions ansible/roles/create-inventory/templates/inventory-mno.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ base_dns_name={{ base_dns_name }}
bastion_lab_interface={{ bastion_lab_interface }}
bastion_controlplane_interface={{ bastion_controlplane_interface }}
controlplane_lab_interface={{ controlplane_lab_interface }}
{% if enable_bond | default(false) %}
bastion_bond0_interface1={{ bastion_bond0_interface1 }}
bastion_bond0_interface2={{ bastion_bond0_interface2 }}
{% endif %}

[bastion]
{{ bastion_machine }} ansible_ssh_user=root bmc_address=mgmt-{{ bastion_machine }} lab_ip={{ bastion_foreman_data.json.ip }}
Expand Down
4 changes: 4 additions & 0 deletions ansible/roles/create-inventory/templates/inventory-sno.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ base_dns_name={{ base_dns_name }}
bastion_lab_interface={{ bastion_lab_interface }}
bastion_controlplane_interface={{ bastion_controlplane_interface }}
controlplane_lab_interface={{ controlplane_lab_interface }}
{% if enable_bond | default(false) %}
bastion_bond0_interface1={{ bastion_bond0_interface1 }}
bastion_bond0_interface2={{ bastion_bond0_interface2 }}
{% endif %}

[bastion]
{{ bastion_machine }} ansible_ssh_user=root bmc_address=mgmt-{{ bastion_machine }} lab_ip={{ bastion_foreman_data.json.ip }}
Expand Down
16 changes: 15 additions & 1 deletion ansible/roles/wait-hosts-discovered/tasks/set_hostname_role.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,29 @@
host_id: "{{ discovered_host.id }}"
host_macs: "{{ (discovered_host.inventory | from_json) | json_query('interfaces[].mac_address') | lower }}"

- name: Set the hostname and role via mac address
- name: Set the hostname and role via mac address (non-bonded)
set_fact:
hostname: "{{ item }}"
host_role: "{{ hostvars[item]['role'] }}"
when:
- lab in rh_labs or lab == "byol"
- not (enable_bond | default(false))
- hostvars[item]['mac_address'] is defined
- hostvars[item]['mac_address'] | lower in host_macs
loop: "{{ inventory_nodes }}"


- name: Set the hostname and role via bond mac addresses (bonded)
set_fact:
hostname: "{{ item }}"
host_role: "{{ hostvars[item]['role'] }}"
when:
- lab in rh_labs or lab == "byol"
- enable_bond | default(false)
- hostvars[item]['bond0_macs'] is defined
- (hostvars[item]['bond0_macs'].split(',')[0] | lower in host_macs) or (hostvars[item]['bond0_macs'].split(',')[1] | lower in host_macs)
loop: "{{ inventory_nodes }}"

- name: Set the hostname and role via bmc address
set_fact:
hostname: "{{ item }}"
Expand Down