Skip to content

Commit

Permalink
Merge pull request #13 from CSCfi/FIX-20181030
Browse files Browse the repository at this point in the history
Allow setting bonding module options and optionally configure nozeroconf on RedHat ifcfg files
  • Loading branch information
Aegil authored Oct 31, 2018
2 parents 7ad2727 + 272e6eb commit a88c66c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 4 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ machines. The role can be used to configure:
- Bonded interfaces
- VLAN tagged interfaces
- Network routes
- Bonding Kernel Module parameters

Requirements
------------
Expand Down Expand Up @@ -91,13 +92,16 @@ define static routes and a gateway.
Note: Routes can also be added for this interface in the same way routes are
added for ethernet interfaces.

3) Configure a bond interface with an "active-backup" slave configuration.
3) Configure a bond-ext interface with an "active-backup" slave configuration.
Also set max_bonds=0 parameter to the bonding kernel module. Preventing
an empty bond0 from being created.
```
- hosts: myhost
roles:
- role: network
network_extra_bonding_module_options: "max_bonds=0"
network_bond_interfaces:
- device: bond0
- device: bond-ext
address: 192.168.10.128
netmask: 255.255.255.0
bootproto: static
Expand All @@ -124,14 +128,17 @@ address obtained via DHCP.
bond_slaves: [eth1, eth2]
```

5) Configure a VLAN interface with the vlan tag 2 for an ethernet interface
5) Configure a VLAN interface with the vlan tag 2 for an ethernet interface
and set nozeroconf to True (no 169.254.0.0/16 link local address).

```
- hosts: myhost
roles:
- role: network
network_ether_interfaces:
- device: eth1
bootproto: static
nozeroconf: True
address: 192.168.10.18
netmask: 255.255.255.0
gateway: 192.168.10.1
Expand Down Expand Up @@ -160,6 +167,7 @@ Describe your network configuration for each host in host vars:
network_ether_interfaces:
- device: eth1
bootproto: static
nozeroconf: True
address: 192.168.10.18
netmask: 255.255.255.0
gateway: 192.168.10.1
Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ network_bond_interfaces: []
network_vlan_interfaces: []
network_check_packages: true
network_allow_service_restart: true
bond_modules_path: "/etc/modprobe.d"
network_extra_bonding_module_options: ""
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
notify:
- restart network

- name: template in bonding.conf module settings
template: src=bonding.conf.j2 dest={{ bond_modules_path}}/bonding.conf
when: network_bond_interfaces is defined and network_extra_bonding_module_options != ""

- name: Make sure the bonding module is loaded
modprobe: name=bonding state=present
when: bond_result is changed
Expand Down
3 changes: 3 additions & 0 deletions templates/bond_RedHat.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ DEFROUTE={{ item.defroute }}
{% if item.mtu is defined %}
MTU={{ item.mtu }}
{% endif %}
{%- if item.nozeroconf is defined -%}
NOZEROCONF={{ item.nozeroconf }}
{% endif %}

{% if item.bonding_master is defined %}
BONDING_MASTER={{ item.bonding_master }}
Expand Down
3 changes: 2 additions & 1 deletion templates/bonding.conf.j2
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
options bonding
# {{ ansible_managed }}
options bonding {{ network_extra_bonding_module_options }}
3 changes: 3 additions & 0 deletions templates/bridge_RedHat.j2
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ DEFROUTE={{ item.defroute }}
{%- if item.mtu is defined -%}
MTU={{ item.mtu }}
{% endif %}
{%- if item.nozeroconf is defined -%}
NOZEROCONF={{ item.nozeroconf }}
{% endif %}
3 changes: 3 additions & 0 deletions templates/ethernet_RedHat.j2
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ DEFROUTE={{ item.defroute }}
{%- if item.mtu is defined -%}
MTU={{ item.mtu }}
{% endif %}
{%- if item.nozeroconf is defined -%}
NOZEROCONF={{ item.nozeroconf }}
{% endif %}

0 comments on commit a88c66c

Please sign in to comment.