Skip to content
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

adding support for "oldskool" manipulations of /etc/network/interfaces, ... #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
53 changes: 40 additions & 13 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,28 @@
dest=/etc/network/interfaces
state=present
insertafter=EOF
when: ansible_os_family == "Debian"
when: ansible_os_family == "Debian" and (oldskool is not defined or not oldskool)

- name: Make sure the include line is not there in interfaces file (oldskool)
lineinfile: >
regexp="^source\ \/etc\/network\/interfaces.d\/\*"
dest=/etc/network/interfaces
state=absent
when: ansible_os_family == "Debian" and oldskool is defined and oldskool

- name: Create the directory for interface cfg files
file: path=/etc/network/interfaces.d state=directory
when: ansible_os_family == "Debian"

- name: Check whether the original interfaces file was already backed up
stat: path=/etc/network/interfaces.d/00interfaces.orig
register: interfacesbackup
when: ansible_os_family == "Debian" and oldskool is defined and oldskool

- name: Backup the original interfaces file
command: cp /etc/network/interfaces /etc/network/interfaces.d/00interfaces.orig
when: ansible_os_family == "Debian" and not interfacesbackup.stat.exists and oldskool is defined and oldskool

- 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
Expand All @@ -39,9 +55,6 @@
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
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 }}
Expand All @@ -54,9 +67,6 @@
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
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 }}
Expand All @@ -66,9 +76,6 @@
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
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 }}
Expand All @@ -85,9 +92,6 @@
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
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 }}
Expand All @@ -97,6 +101,29 @@
when: network_bond_interfaces is defined
register: bond_port_result


- assemble: src=/etc/network/interfaces.d dest=/etc/network/interfaces mode=0644
when: ansible_os_family == "Debian" and oldskool is defined and oldskool

- file: path=/etc/network/interfaces.d/00interfaces.orig state=absent
when: ansible_os_family == "Debian" and (oldskool is not defined or not oldskool)

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

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

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

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

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