diff --git a/tasks/main.yml b/tasks/main.yml index b8b827a..4b3b97f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -15,6 +15,10 @@ when: ansible_os_family == 'Debian' +- name: Remove gateway from /etc/sysconfig/network file + lineinfile: dest=/etc/sysconfig/network regexp=^GATEWAY= state=absent + when: ansible_os_family == 'RedHat' + - name: Make sure the include line is there in interfaces file lineinfile: > regexp="^source\ \/etc\/network\/interfaces.d\/\*" @@ -35,7 +39,7 @@ register: ether_result - name: Write configuration files for rhel route configuration - template: src=route_{{ ansible_os_family }}.j2 dest={{ net_path }}/route-{{ item.device }} + 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' @@ -46,24 +50,24 @@ - 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 + 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 }} + 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 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: + 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 }} @@ -81,7 +85,7 @@ when: bond_result|changed - name: Write configuration files for route configuration - template: src=route_{{ ansible_os_family }}.j2 dest={{ net_path }}/route-{{ item.device }} + 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' @@ -91,7 +95,7 @@ - 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: + with_subelements: - network_bond_interfaces - bond_slaves when: network_bond_interfaces is defined