diff options
author | Markos Chandras <mchandras@suse.de> | 2018-02-15 08:57:47 +0000 |
---|---|---|
committer | Markos Chandras <mchandras@suse.de> | 2018-02-21 17:37:05 +0000 |
commit | cdcfb32414af77abac43440e0ab5b448e72d83e5 (patch) | |
tree | 600f06e58f54db46be3072794237762eb02e72e1 /xci/playbooks/roles/configure-network/tasks | |
parent | 7c37b9ac8715ebedecf903f9de67c55830fb5b90 (diff) |
xci: roles: configure-network: Determine host NIC from Ansible facts
Hardcoding the interface as a variable is very fragile since it varies
from host to host. We could use the Ansible facts to find out the
interface name and then use that to configure all the VLANs and
networking.
Change-Id: Ie7e2409d638625b9bede23b6c1fe33dc36f81840
Signed-off-by: Markos Chandras <mchandras@suse.de>
Diffstat (limited to 'xci/playbooks/roles/configure-network/tasks')
-rw-r--r-- | xci/playbooks/roles/configure-network/tasks/main.yml | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/xci/playbooks/roles/configure-network/tasks/main.yml b/xci/playbooks/roles/configure-network/tasks/main.yml index 65abaa40..adcb8669 100644 --- a/xci/playbooks/roles/configure-network/tasks/main.yml +++ b/xci/playbooks/roles/configure-network/tasks/main.yml @@ -30,7 +30,7 @@ src: "{{ ansible_os_family | lower }}/{{ ansible_hostname }}.interface.j2" dest: "/etc/network/interfaces" - name: restart network service - shell: "/sbin/ifconfig {{ interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a" + shell: "/sbin/ifconfig {{ ansible_default_ipv4.interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a" when: ansible_os_family | lower == "debian" - block: @@ -47,14 +47,14 @@ src: "{{ ansible_os_family | lower }}/suse.interface.j2" dest: "/etc/sysconfig/network/ifcfg-{{ item.name }}" with_items: - - { name: "{{ interface }}" } - - { name: "{{ interface }}.10", vlan_id: 10 } - - { name: "{{ interface }}.30", vlan_id: 30 } - - { name: "{{ interface }}.20", vlan_id: 20 } - - { name: "br-mgmt", bridge_ports: "{{ interface }}.10", ip: "{{ host_info[inventory_hostname].MGMT_IP }}/22" } - - { name: "br-vxlan", bridge_ports: "{{ interface }}.30", ip: "{{ host_info[inventory_hostname].VXLAN_IP }}/22" } - - { name: "br-vlan", bridge_ports: "{{ interface }}", ip: "{{ host_info[inventory_hostname].VLAN_IP }}/24" } - - { name: "br-storage", bridge_ports: "{{ interface }}.20", ip: "{{ host_info[inventory_hostname].STORAGE_IP }}/22" } + - { name: "{{ ansible_default_ipv4.interface }}" } + - { name: "{{ ansible_default_ipv4.interface }}.10", vlan_id: 10 } + - { name: "{{ ansible_default_ipv4.interface }}.30", vlan_id: 30 } + - { name: "{{ ansible_default_ipv4.interface }}.20", vlan_id: 20 } + - { name: "br-mgmt", bridge_ports: "{{ ansible_default_ipv4.interface }}.10", ip: "{{ host_info[inventory_hostname].MGMT_IP }}/22" } + - { name: "br-vxlan", bridge_ports: "{{ ansible_default_ipv4.interface }}.30", ip: "{{ host_info[inventory_hostname].VXLAN_IP }}/22" } + - { name: "br-vlan", bridge_ports: "{{ ansible_default_ipv4.interface }}", ip: "{{ host_info[inventory_hostname].VLAN_IP }}/24" } + - { name: "br-storage", bridge_ports: "{{ ansible_default_ipv4.interface }}.20", ip: "{{ host_info[inventory_hostname].STORAGE_IP }}/22" } - name: Add postup/postdown scripts on SUSE copy: @@ -79,10 +79,10 @@ src: "{{ ansible_os_family | lower }}/interface.ifcfg.j2" dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name }}" with_items: - - { name: "{{ interface }}" , bridge: "br-vlan" } - - { name: "{{ interface }}.10", bridge: "br-mgmt" , vlan_id: 10 } - - { name: "{{ interface }}.20", bridge: "br-storage", vlan_id: 20 } - - { name: "{{ interface }}.30", bridge: "br-vxlan" , vlan_id: 30 } + - { name: "{{ ansible_default_ipv4.interface }}" , bridge: "br-vlan" } + - { name: "{{ ansible_default_ipv4.interface }}.10", bridge: "br-mgmt" , vlan_id: 10 } + - { name: "{{ ansible_default_ipv4.interface }}.20", bridge: "br-storage", vlan_id: 20 } + - { name: "{{ ansible_default_ipv4.interface }}.30", bridge: "br-vxlan" , vlan_id: 30 } - name: Configure networking on CentOS for bridges template: src: "{{ ansible_os_family | lower }}/bridge.ifcfg.j2" |