Skip to content
Open
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
283 changes: 239 additions & 44 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ galaxy_info:
author: "Benno Joy, Martin Verges, Luke Short, Eric Anderson"
company: "AnsibleWorks, First Colo GmbH"
license: BSD-2-Clause
min_ansible_version: 1.9
min_ansible_version: 2.5
platforms:
- name: Debian
versions:
Expand Down
3 changes: 1 addition & 2 deletions tasks/Debian_initial.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
- name: Install the required packages in Debian derivatives
apt:
name: "{{ item }}"
name: "{{ network_pkgs }}"
state: present
loop: "{{ network_pkgs }}"
environment: "{{ env }}"
when: network_check_packages

Expand Down
9 changes: 4 additions & 5 deletions tasks/RedHat_initial.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
- name: Install the required packages in Redhat derivatives
- name: Install the required packages in Redhat derivatives
yum:
name: "{{ item }}"
state: installed
loop: "{{ network_pkgs }}"
name: "{{ network_pkgs }}"
state: present
when: network_check_packages

- name: Write configuration files for rhel route configuration with vlan
Expand Down Expand Up @@ -34,7 +33,7 @@
loop: "{{ network_bridge_interfaces }}"
when: network_bridge_interfaces != [] and item.route is defined

- name: Cleanup gateway dev that does not set to the one we want
- name: Cleanup gateway dev that is not set to the one we want
lineinfile:
dest: /etc/sysconfig/network
regexp: "^GATEWAYDEV=(?!{{ gateway_dev }})"
Expand Down
30 changes: 15 additions & 15 deletions tasks/RedHat_restart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@
state: restarted
when: >
(network_allow_service_restart
and network_service_enabled)
and (ether_result is changed
or bond_port_result is changed
or bond_result is changed
or vlan_result is changed
or bridge_result is changed
or bridge_port_result is changed)
and network_service_enabled)
and (ether_result is changed
or bond_port_result is changed
or bond_result is changed
or vlan_result is changed
or bridge_result is changed
or bridge_port_result is changed)

- name: Restart the "NetworkManager" service on Red Hat systems
service:
name: network
name: NetworkManager
state: restarted
when: >
(network_allow_service_restart
and NetworkManager_service_enabled) and
(ether_result is changed or
bond_port_result is changed or
bond_result is changed or
vlan_result is changed or
bridge_result is changed or
bridge_port_result is changed)
and NetworkManager_service_enabled)
and (ether_result is changed
or bond_port_result is changed
or bond_result is changed
or vlan_result is changed
or bridge_result is changed
or bridge_port_result is changed)
7 changes: 5 additions & 2 deletions tasks/bond_interfaces.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
---
- name: Create the network configuration file for slave in the bond devices
- name: Create the network configuration files for slaves of the bond devices
template:
src: "bond_slave_{{ ansible_os_family }}.j2"
dest: "{{ net_path }}/{{ network_interface_file_prefix }}{{ item.1 }}{{ network_interface_file_postfix }}"
with_subelements:
- "{{ network_bond_interfaces }}"
- bond_slaves
when: not item.1 in network_ether_interfaces|map(attribute='device')|list and
not item.1 in network_bridge_interfaces|map(attribute='device')|list and
not item.1 in network_vlan_interfaces|map(attribute='device')|list
register: bond_port_result
notify: restart networking

- name: Create the network configuration file for bond devices
- name: Create the network configuration files for bond devices
template:
src: "bond_{{ ansible_os_family }}.j2"
dest: "{{ net_path }}/{{ network_interface_file_prefix }}{{ item.device }}{{ network_interface_file_postfix }}"
Expand Down
8 changes: 6 additions & 2 deletions tasks/bridge_interfaces.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
---
- name: Create the network configuration file for bridge devices
- name: Create the network configuration files for bridge devices
template:
src: "bridge_{{ ansible_os_family }}.j2"
dest: "{{ net_path }}/{{ network_interface_file_prefix }}{{ item.device }}{{ network_interface_file_postfix }}"
loop: "{{ network_bridge_interfaces }}"
register: bridge_result
notify: restart networking

- name: Create the network configuration file for port on the bridge devices
- name: Create the network configuration files for ports of the bridge devices
template:
src: "bridge_port_{{ ansible_os_family }}.j2"
dest: "{{ net_path }}/{{ network_interface_file_prefix }}{{ item.1 }}{{ network_interface_file_postfix }}"
with_subelements:
- '{{ network_bridge_interfaces }}'
- bridge_ports
- skip_missing: true
when: not item.1 in network_ether_interfaces|map(attribute='device')|list and
not item.1 in network_bond_interfaces|map(attribute='device')|list and
not item.1 in network_vlan_interfaces|map(attribute='device')|list
register: bridge_port_result
notify: restart networking
2 changes: 1 addition & 1 deletion tasks/ether_interfaces.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Create the network configuration file for ethernet interfaces
- name: Create the network configuration files for ethernet interfaces
template:
src: "ethernet_{{ ansible_os_family }}.j2"
dest: "{{ net_path }}/{{ network_interface_file_prefix }}{{ item.device }}{{ network_interface_file_postfix }}"
Expand Down
2 changes: 1 addition & 1 deletion tasks/vlan_interfaces.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Create the network configuration file for vlan devices
- name: Create the network configuration files for vlan devices
template:
src: "ethernet_{{ ansible_os_family }}.j2"
dest: "{{ net_path }}/{{ network_interface_file_prefix }}{{ item.device }}{{ network_interface_file_postfix }}"
Expand Down
50 changes: 50 additions & 0 deletions templates/Debian_bond_options.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
bond-mode {{ item.bond_mode }}
bond-miimon {{ item.bond_miimon | default(100) }}
{% if item.bond_mode == '802.3ad' or item.bond_mode == 4 %}
bond-lacp-rate {{ item.bond_lacp_rate | default('slow') }}
{% endif %}
{% if item.bond_mode == 2 or item.bond_mode == 'balance-xor'
or item.bond_mode == 4 or item.bond_mode == '802.3ad'
or item.bond_mode == 6 or item.bond_mode == 'balance-tlb'
%}
bond-xmit-hash-policy {{ item.bond_xmit_hash_policy | default('layer3+4') }}
{% endif %}
{% if item.bond_downdelay is defined %}
bond-downdelay {{ item.bond_downdelay }}
{% endif %}
{% if item.bond_updelay is defined %}
bond-updelay {{ item.bond_updelay }}
{% endif %}
{% if item.bond_ad_select is defined %}
bond-ad-select {{ item.bond_ad_select }}
{% endif %}
{% if item.bond_arp_interval is defined %}
bond-arp-interval {{ item.bond_arp_interval }}
{% endif %}
{% if item.bond_arp_ip_target is defined %}
bond-arp-ip-target {{ item.bond_arp_ip_target }}
{% endif %}
{% if item.bond_arp_validate is defined %}
bond-arp-validate {{ item.bond_arp_validate }}
{% endif %}
{% if item.bond_num_grat_arp is defined %}
bond-num-grat-arp {{ item.bond_num_grat_arp }}
{% endif %}
{% if item.bond_num_unsol_na is defined %}
bond-num-unsol-na {{ item.bond_num_unsol_na }}
{% endif %}
{% if item.bond_primary is defined %}
bond-primary {{ item.bond_primary }}
{% endif %}
{% if item.bond_primary_reselect is defined %}
bond-primary-reselect {{ item.bond_primary_reselect }}
{% endif %}
{% if item.bond_use_carrier is defined %}
bond-use-carrier {{ item.bond_use_carrier }}
{% endif %}
{% if item.bond_slaves is defined %}
bond-slaves {{ item.bond_slaves|join(' ') }}
{% endif %}
{% if item.bond_active_slave is defined %}
bond-active-slave {{ item.bond_active_slave }}
{% endif %}
41 changes: 41 additions & 0 deletions templates/Debian_bridge_options.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% if item.bridge_ports is defined %}
bridge_ports {{ item.bridge_ports|join(' ') }}
{% else %}
bridge_ports none
{% endif %}
{% if item.bridge_ageing is defined %}
bridge_ageing {{ item.bridge_ageing }}
{% endif %}
{% if item.bridge_bridgeprio is defined %}
bridge_bridgeprio {{ item.bridge_bridgeprio }}
{% endif %}
{% if item.bridge_fd is defined %}
bridge_fd {{ item.bridge_fd }}
{% endif %}
{% if item.bridge_gcint is defined %}
bridge_gcint {{ item.bridge_gcint }}
{% endif %}
{% if item.bridge_hello is defined %}
bridge_hello {{ item.bridge_hello }}
{% endif %}
{% if item.hwaddress is defined %}
bridge_hw {{ item.hwaddress }}
{% endif %}
{% if item.bridge_maxage is defined %}
bridge_maxage {{ item.bridge_maxage }}
{% endif %}
{% if item.bridge_maxwait is defined %}
bridge_maxwait {{ item.bridge_maxwait }}
{% endif %}
{% if item.bridge_pathcost is defined %}
bridge_pathcost {{ item.bridge_pathcost }}
{% endif %}
{% if item.bridge_portprio is defined %}
bridge_portprio {{ item.bridge_portprio }}
{% endif %}
{% if item.bridge_stp is defined %}
bridge_stp {{ item.bridge_stp }}
{% endif %}
{% if item.bridge_waitport is defined %}
bridge_waitport {{ item.bridge_waitport }}
{% endif %}
27 changes: 27 additions & 0 deletions templates/RedHat_generic_options.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% if item.dns_nameservers is defined %}
{% for dns_nameserver in item.dns_nameservers %}
DNS{{ loop.index }}={{ dns_nameserver }}
{% endfor %}
{% endif -%}

{% if item.nm_controlled is defined %}
NM_CONTROLLED={{ item.nm_controlled | bool | ternary("yes", "no") }}
{% endif -%}

{% if item.defroute is defined %}
DEFROUTE={{ item.defroute | bool | ternary("yes", "no") }}
{% endif -%}

{% if item.stp is defined %}
STP={{ item.stp }}
{% endif -%}

{% if item.mtu is defined %}
MTU={{ item.mtu }}
{% endif -%}

{% if item.firewalld_zone is defined %}
ZONE={{ item.firewalld_zone }}
{% endif -%}

ONBOOT={{ item.onboot|default("yes") }}
15 changes: 15 additions & 0 deletions templates/RedHat_ipv6_options.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% if item.ipv6_address is defined %}
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_FORWARDING="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_PRIVACY="no"
IPV6ADDR={{ item.ipv6_address }}
{% endif -%}

{% if item.ipv6_gateway is defined %}
IPV6_DEFAULTGW="{{ item.ipv6_gateway }}"
{% endif -%}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
VLAN=yes
TYPE=Vlan
{% if item.vlan_physdev is defined %}
PHYSDEV={{ item.vlan_physdev }}
{% else %}
Expand Down
55 changes: 2 additions & 53 deletions templates/bond_Debian.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# {{ ansible_managed }}

auto {{ item.device }}
iface {{ item.device }} inet {% if item.bootproto is defined %}{{ item.bootproto }}{% elif item.cidr is defined or item.address is defined %}static{% else %}dhcp{% endif %}
Expand All @@ -6,60 +7,8 @@ iface {{ item.device }} inet {% if item.bootproto is defined %}{{ item.bootproto
{% include 'Debian_resolvconf.j2' %}
{% include 'route_Debian.j2' %}

{% if item.bond_mode is defined and item.bond_slaves is defined %}
{% if item.bond_mode is defined %}
bond-mode {{ item.bond_mode }}
bond-miimon {{ item.bond_miimon | default(100) }}
{% if item.bond_mode == '802.3ad' or item.bond_mode == 4 %}
bond-lacp-rate {{ item.bond_lacp_rate | default('slow') }}
{% endif %}
{% if item.bond_mode == 2 or item.bond_mode == 'balance-xor'
or item.bond_mode == 4 or item.bond_mode == '802.3ad'
or item.bond_mode == 6 or item.bond_mode == 'balance-tlb'
%}
bond-xmit-hash-policy {{ item.bond_xmit_hash_policy | default('layer3+4') }}
{% endif %}

{% if item.bond_downdelay is defined %}
bond-downdelay {{ item.bond_downdelay }}
{% endif %}
{% if item.bond_updelay is defined %}
bond-updelay {{ item.bond_updelay }}
{% endif %}
{% if item.bond_ad_select is defined %}
bond-ad-select {{ item.bond_ad_select }}
{% endif %}
{% if item.bond_arp_interval is defined %}
bond-arp-interval {{ item.bond_arp_interval }}
{% endif %}
{% if item.bond_arp_ip_target is defined %}
bond-arp-ip-target {{ item.bond_arp_ip_target }}
{% endif %}
{% if item.bond_arp_validate is defined %}
bond-arp-validate {{ item.bond_arp_validate }}
{% endif %}
{% if item.bond_num_grat_arp is defined %}
bond-num-grat-arp {{ item.bond_num_grat_arp }}
{% endif %}
{% if item.bond_num_unsol_na is defined %}
bond-num-unsol-na {{ item.bond_num_unsol_na }}
{% endif %}
{% if item.bond_primary is defined %}
bond-primary {{ item.bond_primary }}
{% endif %}
{% if item.bond_primary_reselect is defined %}
bond-primary-reselect {{ item.bond_primary_reselect }}
{% endif %}
{% if item.bond_use_carrier is defined %}
bond-use-carrier {{ item.bond_use_carrier }}
{% endif %}
{% if item.bond_slaves is defined %}
bond-slaves {{ item.bond_slaves|join(' ') }}
{% endif %}
{% if item.bond_active_slave is defined %}
bond-active-slave {{ item.bond_active_slave }}
{% endif %}
{% endif %}
{% include 'Debian_bond_options.j2' %}
{% endif %}

{% if item.hwaddress is defined %}
Expand Down
Loading