Skip to content

Commit da4b088

Browse files
author
Mark Stansberry
committed
Add modprobe tasks to load/persist vlan
1 parent bf74a02 commit da4b088

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

defaults/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ network_bond_interfaces: []
66
network_vlan_interfaces: []
77
network_check_packages: true
88
network_allow_service_restart: true
9+
network_modprobe_persist: true

tasks/main.yml

+31-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
src: "bond_slave_{{ ansible_os_family }}.j2"
2424
dest: "{{ net_path }}/ifcfg-{{ item.1 }}"
2525
with_subelements:
26-
- "{{ network_bond_interfaces }}"
27-
- bond_slaves
26+
- "{{ network_bond_interfaces }}"
27+
- bond_slaves
2828
when: network_bond_interfaces is defined
2929
register: bond_port_result
3030

@@ -33,23 +33,49 @@
3333
src: "bond_{{ ansible_os_family }}.j2"
3434
dest: "{{ net_path }}/ifcfg-{{ item.device }}"
3535
with_items: "{{ network_bond_interfaces }}"
36-
when: network_bond_interfaces is defined
36+
when: network_bond_interfaces
3737
register: bond_result
3838

3939
- name: Make sure the bonding module is loaded
4040
modprobe:
4141
name: bonding
4242
state: present
43-
when: bond_result|changed
43+
when: bond_result is changed
44+
45+
- name: Make the bonding module persistent
46+
become: true
47+
lineinfile:
48+
line: 'bonding'
49+
dest: /etc/modules
50+
insertafter: EOF
51+
when:
52+
- network_bond_interfaces
53+
- network_modprobe_persist
4454

4555
- name: Create the network configuration file for vlan devices
4656
template:
4757
src: "ethernet_{{ ansible_os_family }}.j2"
4858
dest: "{{ net_path }}/ifcfg-{{ item.device }}"
4959
with_items: "{{ network_vlan_interfaces }}"
50-
when: network_vlan_interfaces is defined
60+
when: network_vlan_interfaces
5161
register: vlan_result
5262

63+
- name: Make sure the 8021q module is loaded
64+
modprobe:
65+
name: 8021q
66+
state: present
67+
when: vlan_result is changed
68+
69+
- name: Make the 8021q module persistent
70+
become: true
71+
lineinfile:
72+
line: '8021q'
73+
dest: /etc/modules
74+
insertafter: EOF
75+
when:
76+
- network_vlan_interfaces
77+
- network_modprobe_persist
78+
5379
- name: Create the network configuration file for bridge devices
5480
template:
5581
src: "bridge_{{ ansible_os_family }}.j2"

0 commit comments

Comments
 (0)