Skip to content

Commit 72bc337

Browse files
Merge pull request #629 from akrzos/sno_public_vlan_address
Autoconfigure SNO public_vlan
2 parents ea12e85 + f1aa6eb commit 72bc337

File tree

9 files changed

+51
-28
lines changed

9 files changed

+51
-28
lines changed

ansible/roles/create-inventory/tasks/main.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,28 @@
3636
ocpinventory_sno_nodes: []
3737
ocpinventory_hv_nodes: []
3838

39-
- name: Public VLAN in MNO cluster
40-
when: public_vlan and cluster_type == "mno"
39+
- name: Public VLAN autoconfiguration
40+
when: public_vlan
4141
block:
4242
- name: Public VLAN - Set controlplane_network_interface_idx to -1 for the last interface
4343
set_fact:
4444
controlplane_network_interface_idx: "-1"
4545

46-
- name: Get assignment from scalelab quads
46+
- name: Public VLAN - Get assignment from quads
4747
uri:
4848
url: "https://{{ labs[lab]['quads'] }}/api/v3/assignments/active/{{ lab_cloud }}"
4949
force_basic_auth: yes
5050
user: "{{ lab_cloud }}"
5151
password: "{{ ocpinventory.json.nodes[0].pm_password }}"
5252
validate_certs: false
5353
register: quads_assignment
54-
when: lab == "scalelab" or lab == "performancelab"
5554

56-
- name: Public scalelab VLAN - Set addressing information
55+
- name: Public VLAN - Set addressing information
5756
set_fact:
5857
controlplane_network: "{{ quads_assignment.json.vlan.ip_range }}"
5958
controlplane_network_prefix: "{{ quads_assignment.json.vlan.ip_range | ipaddr('prefix') }}"
6059
controlplane_network_gateway: "{{ quads_assignment.json.vlan.gateway }}"
6160
cluster_name: "vlan{{ quads_assignment.json.vlan.vlan_id }}"
62-
when: lab == "scalelab" or lab == "performancelab"
6361

6462
- name: Multi node cluster type tasks
6563
when: cluster_type == "mno"

ansible/roles/create-inventory/templates/inventory-sno.j2

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,19 @@ bmc_password={{ bmc_password }}
4141
# one at a time by rerunning the SNO deploy playbook after changing which inventory line
4242
# is uncommented
4343
{% for sno in ocpinventory_sno_nodes %}
44-
{% set sno_long_hostname=sno.pm_addr | replace('mgmt-','') %}
45-
{% set sno_short_hostname=(sno_long_hostname.split('.')[0]) %}
46-
{% set lab_mac=(sno_foreman_data.results|selectattr('json.name', 'eq', sno_long_hostname)|first) | json_query(mac_query) | join(', ') %}
47-
{% if sno_use_lab_dhcp %}
48-
{% set ip=(sno_foreman_data.results|selectattr('json.name', 'eq', sno_long_hostname)|first).json.ip %}
49-
{% else %}
50-
{% set ip=controlplane_network | ansible.utils.nthhost(loop.index0 + 5) %}
51-
{% endif %}
52-
{% if not loop.first %}# {% endif %}{{ sno_short_hostname }} bmc_address={{ sno.pm_addr }} mac_address={{ sno.mac[controlplane_network_interface_idx] }} lab_mac={{ lab_mac }} ip={{ ip }} vendor={{ hw_vendor[(sno.pm_addr.split('.')[0]).split('-')[-1]] }} install_disk={{ sno_install_disk }} boot_iso={{ sno_short_hostname }}.iso
44+
{% set sno_long_hostname=sno.pm_addr | replace('mgmt-','') %}
45+
{% if public_vlan and loop.first %}
46+
{% set sno_short_hostname=cluster_name %}
47+
{% else %}
48+
{% set sno_short_hostname=(sno_long_hostname.split('.')[0]) %}
49+
{% endif %}
50+
{% set lab_mac=(sno_foreman_data.results|selectattr('json.name', 'eq', sno_long_hostname)|first) | json_query(mac_query) | join(', ') %}
51+
{% if sno_use_lab_dhcp %}
52+
{% set ip=(sno_foreman_data.results|selectattr('json.name', 'eq', sno_long_hostname)|first).json.ip %}
53+
{% else %}
54+
{% set ip=controlplane_network | ansible.utils.nthhost(loop.index0 + 3) %}
55+
{% endif %}
56+
{% if not loop.first %}# {% endif %}{{ sno_short_hostname }} bmc_address={{ sno.pm_addr }} mac_address={{ sno.mac[controlplane_network_interface_idx|int] }} lab_mac={{ lab_mac }} ip={{ ip }} vendor={{ hw_vendor[(sno.pm_addr.split('.')[0]).split('-')[-1]] }} install_disk={{ sno_install_disk }} boot_iso={{ sno_short_hostname }}.iso
5357
{% endfor %}
5458

5559
[sno:vars]

ansible/roles/validate-vars/tasks/main.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@
2727
- name: Validate public_vlan
2828
fail:
2929
msg: "Public vlan can only be set with non-byol Red Hat Labs."
30-
when: (public_vlan | default(false)) and (lab == "byol")
30+
when:
31+
- public_vlan | default(false)
32+
- lab == "byol"
33+
34+
- name: Validate public_vlan and sno_use_lab_dhcp
35+
fail:
36+
msg: "public_vlan and sno_use_lab_dhcp can not both be true, only enable one or the other"
37+
when:
38+
- public_vlan | default(false)
39+
- sno_use_lab_dhcp | default(false)
3140

3241
- name: Check for RHEL/Centos (Bastion Validation)
3342
fail:

ansible/vars/all.sample.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ ocp_build: "ga"
2424
ocp_version: "latest-4.18"
2525

2626
# Set to true ONLY if you have a public routable vlan in your scalelab or performancelab cloud.
27-
# MNO clusters autoconfigure cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
27+
# Autoconfigures cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
2828
# controlplane_network_prefix, and controlplane_network_gateway to the values required for your cloud's public VLAN.
29-
# SNOs require manual configuration with additional variables.
29+
# SNO configures only the first cluster on the api dns resolvable address
30+
# MNO/SNO still requires the correct value for bastion_controlplane_interface
3031
public_vlan: false
3132

3233
# SNOs only require a single IP address and can be deployed using the lab DHCP interface instead of a private or
3334
# public vlan network. Set to true to have your SNO deployed on the public lab DHCP network.
35+
# Cannot combine public_vlan and sno_use_lab_dhcp
3436
sno_use_lab_dhcp: false
3537

3638
# Enables FIPs security standard

docs/deploy-mno-byol.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,15 @@ ocp_build: "ga"
290290
ocp_version: "latest-4.18"
291291

292292
# Set to true ONLY if you have a public routable vlan in your scalelab or performancelab cloud.
293-
# MNO clusters autoconfigure cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
293+
# Autoconfigures cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
294294
# controlplane_network_prefix, and controlplane_network_gateway to the values required for your cloud's public VLAN.
295-
# SNOs require manual configuration with additional variables.
295+
# SNO configures only the first cluster on the api dns resolvable address
296+
# MNO/SNO still requires the correct value for bastion_controlplane_interface
296297
public_vlan: false
297298

298299
# SNOs only require a single IP address and can be deployed using the lab DHCP interface instead of a private or
299300
# public vlan network. Set to true to have your SNO deployed on the public lab DHCP network.
301+
# Cannot combine public_vlan and sno_use_lab_dhcp
300302
sno_use_lab_dhcp: false
301303

302304
# Enables FIPs security standard

docs/deploy-mno-performancelab.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,15 @@ ocp_build: "ga"
363363
ocp_version: "latest-4.18"
364364

365365
# Set to true ONLY if you have a public routable vlan in your scalelab or performancelab cloud.
366-
# MNO clusters autoconfigure cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
366+
# Autoconfigures cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
367367
# controlplane_network_prefix, and controlplane_network_gateway to the values required for your cloud's public VLAN.
368-
# SNOs require manual configuration with additional variables.
368+
# SNO configures only the first cluster on the api dns resolvable address
369+
# MNO/SNO still requires the correct value for bastion_controlplane_interface
369370
public_vlan: false
370371

371372
# SNOs only require a single IP address and can be deployed using the lab DHCP interface instead of a private or
372373
# public vlan network. Set to true to have your SNO deployed on the public lab DHCP network.
374+
# Cannot combine public_vlan and sno_use_lab_dhcp
373375
sno_use_lab_dhcp: false
374376

375377
# Enables FIPs security standard

docs/deploy-mno-scalelab.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,15 @@ ocp_build: "ga"
360360
ocp_version: "latest-4.18"
361361

362362
# Set to true ONLY if you have a public routable vlan in your scalelab or performancelab cloud.
363-
# MNO clusters autoconfigure cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
363+
# Autoconfigures cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
364364
# controlplane_network_prefix, and controlplane_network_gateway to the values required for your cloud's public VLAN.
365-
# SNOs require manual configuration with additional variables.
365+
# SNO configures only the first cluster on the api dns resolvable address
366+
# MNO/SNO still requires the correct value for bastion_controlplane_interface
366367
public_vlan: false
367368

368369
# SNOs only require a single IP address and can be deployed using the lab DHCP interface instead of a private or
369370
# public vlan network. Set to true to have your SNO deployed on the public lab DHCP network.
371+
# Cannot combine public_vlan and sno_use_lab_dhcp
370372
sno_use_lab_dhcp: false
371373

372374
# Enables FIPs security standard

docs/deploy-sno-performancelab.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,15 @@ ocp_build: "ga"
362362
ocp_version: "latest-4.18"
363363

364364
# Set to true ONLY if you have a public routable vlan in your scalelab or performancelab cloud.
365-
# MNO clusters autoconfigure cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
365+
# Autoconfigures cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
366366
# controlplane_network_prefix, and controlplane_network_gateway to the values required for your cloud's public VLAN.
367-
# SNOs require manual configuration with additional variables.
367+
# SNO configures only the first cluster on the api dns resolvable address
368+
# MNO/SNO still requires the correct value for bastion_controlplane_interface
368369
public_vlan: false
369370

370371
# SNOs only require a single IP address and can be deployed using the lab DHCP interface instead of a private or
371372
# public vlan network. Set to true to have your SNO deployed on the public lab DHCP network.
373+
# Cannot combine public_vlan and sno_use_lab_dhcp
372374
sno_use_lab_dhcp: false
373375

374376
# Enables FIPs security standard

docs/deploy-sno-scalelab.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,15 @@ ocp_build: "ga"
393393
ocp_version: "latest-4.18"
394394

395395
# Set to true ONLY if you have a public routable vlan in your scalelab or performancelab cloud.
396-
# MNO clusters autoconfigure cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
396+
# Autoconfigures cluster_name, base_dns_name, controlplane_network_interface_idx, controlplane_network,
397397
# controlplane_network_prefix, and controlplane_network_gateway to the values required for your cloud's public VLAN.
398-
# SNOs require manual configuration with additional variables.
398+
# SNO configures only the first cluster on the api dns resolvable address
399+
# MNO/SNO still requires the correct value for bastion_controlplane_interface
399400
public_vlan: false
400401

401402
# SNOs only require a single IP address and can be deployed using the lab DHCP interface instead of a private or
402403
# public vlan network. Set to true to have your SNO deployed on the public lab DHCP network.
404+
# Cannot combine public_vlan and sno_use_lab_dhcp
403405
sno_use_lab_dhcp: false
404406

405407
# Enables FIPs security standard

0 commit comments

Comments
 (0)