Skip to content

Adhere to ansible 2.x #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
50 changes: 25 additions & 25 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

- name: Install the required packages in Redhat derivatives
yum: name={{ item }} state=installed
with_items: network_pkgs
with_items: "{{ network_pkgs }}"
when: ansible_os_family == 'RedHat'

- name: Install the required packages in Debian derivatives
apt: name={{ item }} state=installed update_cache=yes
with_items: network_pkgs
environment: env
with_items: "{{ network_pkgs }}"
environment: "{{ env }}"
when: ansible_os_family == 'Debian'


Expand All @@ -30,49 +30,49 @@

- name: Create the network configuration file for ethernet devices
template: src=ethernet_{{ ansible_os_family }}.j2 dest={{ net_path }}/ifcfg-{{ item.device }}
with_items: network_ether_interfaces
with_items: "{{ network_ether_interfaces }}"
when: network_ether_interfaces is defined
register: ether_result

- name: Write configuration files for rhel route configuration
template: src=route_{{ ansible_os_family }}.j2 dest={{ net_path }}/route-{{ item.device }}
with_items: network_ether_interfaces
template: src=route_{{ ansible_os_family }}.j2 dest={{ net_path }}/route-{{ item.device }}
with_items: "{{ network_ether_interfaces }}"
when: network_ether_interfaces is defined and item.route is defined and ansible_os_family == 'RedHat'

- shell: ifdown {{ item.item.device }}; ifup {{ item.item.device }}
with_items: ether_result.results
with_items: "{{ ether_result.results }}"
when: ether_result is defined and item.changed

- name: Create the network configuration file for bridge devices
template: src=bridge_{{ ansible_os_family }}.j2 dest={{ net_path }}/ifcfg-{{ item.device }}
with_items: network_bridge_interfaces
when: network_bridge_interfaces is defined
with_items: "{{ network_bridge_interfaces }}"
when: network_bridge_interfaces is defined
register: bridge_result

- name: Write configuration files for rhel route configuration
template: src=route_{{ ansible_os_family }}.j2 dest={{ net_path }}/route-{{ item.device }}
with_items: network_bridge_interfaces
template: src=route_{{ ansible_os_family }}.j2 dest={{ net_path }}/route-{{ item.device }}
with_items: "{{ network_bridge_interfaces }}"
when: network_bridge_interfaces is defined and item.route is defined and ansible_os_family == 'RedHat'

- shell: ifdown {{ item.item.device }}; ifup {{ item.item.device }}
with_items: bridge_result.results
with_items: "{{bridge_result.results}}"
when: bridge_result is defined and item.changed

- name: Create the network configuration file for port on the bridge devices
template: src=bridge_port_{{ ansible_os_family }}.j2 dest={{ net_path }}/ifcfg-{{ item.1 }}
with_subelements:
- network_bridge_interfaces
with_subelements:
- "{{ network_bridge_interfaces }}"
- ports
when: network_bridge_interfaces is defined
when: network_bridge_interfaces is defined
register: bridge_port_result

- shell: ifdown {{ item.item.1 }}; ifup {{ item.item.1 }}
with_items: bridge_port_result.results
with_items: "{{bridge_port_result.results}}"
when: bridge_port_result is defined and item.changed

- name: Create the network configuration file for bond devices
template: src=bond_{{ ansible_os_family }}.j2 dest={{ net_path }}/ifcfg-{{ item.device }}
with_items: network_bond_interfaces
with_items: "{{ network_bond_interfaces }}"
when: network_bond_interfaces is defined
register: bond_result

Expand All @@ -81,26 +81,26 @@
when: bond_result|changed

- name: Write configuration files for route configuration
template: src=route_{{ ansible_os_family }}.j2 dest={{ net_path }}/route-{{ item.device }}
with_items: network_bond_interfaces
template: src=route_{{ ansible_os_family }}.j2 dest={{ net_path }}/route-{{ item.device }}
with_items: "{{ network_bond_interfaces }}"
when: network_bond_interfaces is defined and item.route is defined and ansible_os_family == 'RedHat'

- shell: ifdown {{ item.item.device }}; ifup {{ item.item.device }}
with_items: bond_result.results
with_items: "{{bond_result.results}}"
when: bond_result is defined and item.changed

- name: Create the network configuration file for slave in the bond devices
template: src=bond_slave_{{ ansible_os_family }}.j2 dest={{ net_path }}/ifcfg-{{ item.1 }}
with_subelements:
- network_bond_interfaces
with_subelements:
- "{{ network_bond_interfaces }}"
- bond_slaves
when: network_bond_interfaces is defined
register: bond_port_result

- shell: ifdown {{ item.item.1 }}; ifup {{ item.item.1 }}
with_items: bond_port_result.results
with_items: "{{ bond_port_result.results }}"
when: bond_port_result is defined and item.changed

- shell: ifdown {{ item.item.device }}; ifup {{ item.item.device }}
with_items: bond_result.results
with_items: "{{ bond_result.results }}"
when: bond_result is defined and item.changed and ansible_os_family == 'RedHat'
5 changes: 5 additions & 0 deletions templates/ethernet_Debian.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ auto {{ item.device }}
iface {{ item.device }} inet dhcp
{% endif %}

{% if item.bootproto == 'manual' %}
auto {{ item.device }}
iface {{ item.device }} inet manual
{% endif %}

{% if item.route is defined %}
{% for i in item.route %}
up route add -net {{ i.network }} netmask {{ i.netmask }} gw {{ i.gateway }} dev {{ item.device }}
Expand Down