Skip to content

Commit e80a0d8

Browse files
Tagged VLAN of top of bond (#754)
* Tagged VLAN of top of bond Signed-off-by: Jose Castillo Lema <josecastillolema@gmail.com> * Configure bastion as well Signed-off-by: Jose Castillo Lema <josecastillolema@gmail.com> * Fix DHCP issue with bond0 Signed-off-by: Jose Castillo Lema <josecastillolema@gmail.com> --------- Signed-off-by: Jose Castillo Lema <josecastillolema@gmail.com>
1 parent e5675ff commit e80a0d8

File tree

6 files changed

+186
-3
lines changed

6 files changed

+186
-3
lines changed

ansible/roles/bastion-network/tasks/main.yml

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,23 @@
109109
mode: 802.3ad
110110
miimon: 100
111111
state: present
112-
when: controlplane_network | length > 1
112+
when:
113+
- controlplane_network | length > 1
114+
- not enable_bond_vlan | default(false)
115+
116+
- name: Create bond0 connection for bastion without IPs (dual stack with VLAN)
117+
nmcli:
118+
type: bond
119+
conn_name: bond0
120+
ifname: bond0
121+
method4: disabled
122+
method6: disabled
123+
mode: 802.3ad
124+
miimon: 100
125+
state: present
126+
when:
127+
- controlplane_network | length > 1
128+
- enable_bond_vlan | default(false)
113129

114130
- name: Create bond0 connection for bastion (single stack IPv4)
115131
nmcli:
@@ -120,7 +136,25 @@
120136
mode: 802.3ad
121137
miimon: 100
122138
state: present
123-
when: controlplane_network | length == 1 and controlplane_network[0] | ansible.utils.ipv4
139+
when:
140+
- controlplane_network | length == 1
141+
- controlplane_network[0] | ansible.utils.ipv4
142+
- not enable_bond_vlan | default(false)
143+
144+
- name: Create bond0 connection for bastion without IPs (single stack IPv4 with VLAN)
145+
nmcli:
146+
type: bond
147+
conn_name: bond0
148+
ifname: bond0
149+
method4: disabled
150+
method6: disabled
151+
mode: 802.3ad
152+
miimon: 100
153+
state: present
154+
when:
155+
- controlplane_network | length == 1
156+
- controlplane_network[0] | ansible.utils.ipv4
157+
- enable_bond_vlan | default(false)
124158

125159
- name: Create bond0 connection for bastion (single stack IPv6)
126160
nmcli:
@@ -131,7 +165,25 @@
131165
mode: 802.3ad
132166
miimon: 100
133167
state: present
134-
when: controlplane_network | length == 1 and controlplane_network[0] | ansible.utils.ipv6
168+
when:
169+
- controlplane_network | length == 1
170+
- controlplane_network[0] | ansible.utils.ipv6
171+
- not enable_bond_vlan | default(false)
172+
173+
- name: Create bond0 connection for bastion without IPs (single stack IPv6 with VLAN)
174+
nmcli:
175+
type: bond
176+
conn_name: bond0
177+
ifname: bond0
178+
method4: disabled
179+
method6: disabled
180+
mode: 802.3ad
181+
miimon: 100
182+
state: present
183+
when:
184+
- controlplane_network | length == 1
185+
- controlplane_network[0] | ansible.utils.ipv6
186+
- enable_bond_vlan | default(false)
135187

136188
- name: Add first interface as bond slave
137189
nmcli:
@@ -149,6 +201,49 @@
149201
master: bond0
150202
state: present
151203

204+
# VLAN subinterface configuration when enabled
205+
- name: Create VLAN subinterface for bastion (dual stack)
206+
nmcli:
207+
type: vlan
208+
conn_name: "{{ bond_vlan_interface_name | default('bond0.' + (bond_vlan_id | string)) }}"
209+
ifname: "{{ bond_vlan_interface_name | default('bond0.' + (bond_vlan_id | string)) }}"
210+
vlanid: "{{ bond_vlan_id | default(10) }}"
211+
vlandev: bond0
212+
ip4: "{{ controlplane_network[0] | ansible.utils.nthhost(1) }}/{{ controlplane_network_prefix[0] }}"
213+
ip6: "{{ controlplane_network[1] | ansible.utils.nthhost(1) }}/{{ controlplane_network_prefix[1] }}"
214+
state: present
215+
when:
216+
- enable_bond_vlan | default(false)
217+
- controlplane_network | length > 1
218+
219+
- name: Create VLAN subinterface for bastion (single stack IPv4)
220+
nmcli:
221+
type: vlan
222+
conn_name: "{{ bond_vlan_interface_name | default('bond0.' + (bond_vlan_id | string)) }}"
223+
ifname: "{{ bond_vlan_interface_name | default('bond0.' + (bond_vlan_id | string)) }}"
224+
vlanid: "{{ bond_vlan_id | default(10) }}"
225+
vlandev: bond0
226+
ip4: "{{ controlplane_network[0] | ansible.utils.nthhost(1) }}/{{ controlplane_network_prefix[0] }}"
227+
state: present
228+
when:
229+
- enable_bond_vlan | default(false)
230+
- controlplane_network | length == 1
231+
- controlplane_network[0] | ansible.utils.ipv4
232+
233+
- name: Create VLAN subinterface for bastion (single stack IPv6)
234+
nmcli:
235+
type: vlan
236+
conn_name: "{{ bond_vlan_interface_name | default('bond0.' + (bond_vlan_id | string)) }}"
237+
ifname: "{{ bond_vlan_interface_name | default('bond0.' + (bond_vlan_id | string)) }}"
238+
vlanid: "{{ bond_vlan_id | default(10) }}"
239+
vlandev: bond0
240+
ip6: "{{ controlplane_network[0] | ansible.utils.nthhost(1) }}/{{ controlplane_network_prefix[0] }}"
241+
state: present
242+
when:
243+
- enable_bond_vlan | default(false)
244+
- controlplane_network | length == 1
245+
- controlplane_network[0] | ansible.utils.ipv6
246+
152247
# Single interface configuration for non-bonded setups
153248
- name: Setup bastion single interface configuration
154249
when:

ansible/roles/create-ai-cluster/templates/rhlab_bond_nmstate.yml.j2

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ interfaces:
22
- name: bond0
33
type: bond
44
state: up
5+
{% if enable_bond_vlan | default(false) %}
6+
ipv4:
7+
auto-dns: false
8+
enabled: false
9+
{% else %}
510
{% if 'ip' in hostvars[item] %}
611
ipv4:
712
address:
@@ -17,6 +22,7 @@ interfaces:
1722
prefix-length: {{ hostvars[item]['ipv6_prefix'] }}
1823
auto-dns: false
1924
enabled: true
25+
{% endif %}
2026
{% endif %}
2127
link-aggregation:
2228
mode: 802.3ad
@@ -27,6 +33,30 @@ interfaces:
2733
{% for interface in hostvars[item]['bond0_interfaces'] %}
2834
- {{ interface }}
2935
{% endfor %}
36+
{% if enable_bond_vlan | default(false) %}
37+
- name: {{ bond_vlan_interface_name | default('bond0.' + (bond_vlan_id | string)) }}
38+
type: vlan
39+
state: up
40+
{% if 'ip' in hostvars[item] %}
41+
ipv4:
42+
address:
43+
- ip: {{ hostvars[item]['ip'] }}
44+
prefix-length: {{ hostvars[item]['network_prefix'] }}
45+
auto-dns: false
46+
enabled: true
47+
{% endif %}
48+
{% if 'ipv6' in hostvars[item] %}
49+
ipv6:
50+
address:
51+
- ip: {{ hostvars[item]['ipv6'] }}
52+
prefix-length: {{ hostvars[item]['ipv6_prefix'] }}
53+
auto-dns: false
54+
enabled: true
55+
{% endif %}
56+
vlan:
57+
base-iface: bond0
58+
id: {{ bond_vlan_id | default(10) }}
59+
{% endif %}
3060
- name: {{ hostvars[item]['lab_interface']}}
3161
type: ethernet
3262
state: up
@@ -45,10 +75,18 @@ routes:
4575
{% if 'ip' in hostvars[item] %}
4676
- destination: 0.0.0.0/0
4777
next-hop-address: {{ hostvars[item]['gateway'] }}
78+
{% if enable_bond_vlan | default(false) %}
79+
next-hop-interface: {{ bond_vlan_interface_name | default('bond0.' + (bond_vlan_id | string)) }}
80+
{% else %}
4881
next-hop-interface: bond0
4982
{% endif %}
83+
{% endif %}
5084
{% if 'ipv6' in hostvars[item] %}
5185
- destination: ::/0
5286
next-hop-address: {{ hostvars[item]['ipv6_gateway'] }}
87+
{% if enable_bond_vlan | default(false) %}
88+
next-hop-interface: {{ bond_vlan_interface_name | default('bond0.' + (bond_vlan_id | string)) }}
89+
{% else %}
5390
next-hop-interface: bond0
5491
{% endif %}
92+
{% endif %}

ansible/roles/create-inventory/defaults/main/networks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@ bond0_port2: 2
5252
private_bond_interfaces:
5353
- eth0
5454
- eth1
55+
56+
# Bond VLAN configuration defaults
57+
enable_bond_vlan: false
58+
bond_vlan_id: 10

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@
5252
- enable_bond | default(false)
5353
- sno_use_lab_dhcp | default(false)
5454

55+
- name: Validate enable_bond_vlan requires enable_bond
56+
fail:
57+
msg: "enable_bond_vlan requires enable_bond to be true"
58+
when:
59+
- enable_bond_vlan | default(false)
60+
- not (enable_bond | default(false))
61+
62+
- name: Validate bond_vlan_id range
63+
fail:
64+
msg: "bond_vlan_id must be between 1 and 4094"
65+
when:
66+
- enable_bond_vlan | default(false)
67+
- bond_vlan_id | default(10) < 1 or bond_vlan_id | default(10) > 4094
68+
5569
- name: Check for RHEL/Centos (Bastion Validation)
5670
fail:
5771
msg: "Expecting RHEL or Centos for a Bastion OS"

ansible/vars/all.sample.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ use_bastion_registry: false
8989
# Only works with private VLANs (public_vlan: false) and homogeneous hardware
9090
enable_bond: false
9191

92+
# VLAN subinterface on bond configuration (requires enable_bond: true)
93+
# Enable VLAN subinterface on top of bond0 interface
94+
# When enabled, creates bond0.<vlan_id> interface with specified VLAN tag
95+
enable_bond_vlan: false
96+
# VLAN ID for the subinterface (1-4094)
97+
bond_vlan_id: 10
98+
# Name for the VLAN subinterface (defaults to bond0.<vlan_id>)
99+
# bond_vlan_interface_name: bond0.10
100+
92101
################################################################################
93102
# Single Stack IPv4 Network Configuration
94103
################################################################################

docs/tips-and-vars.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,29 @@ When enabled, uses the first two network interfaces by default (indices 1 & 2).
252252
Only works with private networks (`public_vlan: false`) and homogeneous hardware.
253253
At the moment QUADS does not expose any APIs for this kind of networking setup in the labs, so unless you have discussed your particular use case with the DevOps team and the network setup of your cloud allocation is ready to accommodate this config, please disconsider this option.
254254

255+
#### VLAN subinterface on bonding
256+
Additionally, you can enable VLAN subinterfaces on top of bond0 using the following configuration:
257+
258+
```yaml
259+
enable_bond: true
260+
enable_bond_vlan: true
261+
bond_vlan_id: 10
262+
# bond_vlan_interface_name: bond0.10 # Optional: defaults to bond0.<vlan_id>
263+
```
264+
265+
This creates a VLAN subinterface (bond0.10) on top of the bond0 interface with the specified VLAN tag. The IP addresses are assigned to the VLAN subinterface instead of the bond0 interface directly.
266+
267+
**What this configures:**
268+
- **Bastion host**: Creates bond0 (no IP) + bond0.10 (with controlplane IP) using nmcli
269+
- **Cluster nodes**: Creates bond0 (no IP) + bond0.10 (with node IPs) using nmstate
270+
- **Network routing**: All traffic flows through the VLAN subinterface
271+
272+
**Requirements:**
273+
- `enable_bond` must be set to `true`
274+
- `bond_vlan_id` must be between 1-4094
275+
- Only works with private networks (`public_vlan: false`)
276+
- Network infrastructure must support the specified VLAN tag
277+
255278
## Configuring NVMe install and etcd disks
256279

257280
If you require the install disk or etcd disk to be on a specific drive (different from

0 commit comments

Comments
 (0)