From 6ef18dbe7c5a517cc3cd4e85c281b1260d7e0fc9 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 16 Jun 2016 17:34:07 -0600 Subject: [PATCH] Improve network interface discovery Signed-off-by: Zack Cerza --- roles/testnode/tasks/resolvconf.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/testnode/tasks/resolvconf.yml b/roles/testnode/tasks/resolvconf.yml index caeab47..c57ca57 100644 --- a/roles/testnode/tasks/resolvconf.yml +++ b/roles/testnode/tasks/resolvconf.yml @@ -8,7 +8,7 @@ - name: Set interface set_fact: - interface: "{{ hostvars[inventory_hostname].interface|default('eth0') }}" + interface: "{{ ansible_default_ipv4.interface }}" - name: Check for presence of /etc/network/interfaces stat: @@ -41,7 +41,9 @@ - name: ifdown and ifup shell: "ifdown {{ interface }} && ifup {{ interface }}" # Even if bounce_interface is False, we need to work around a Xenial issue - # where removing resolvconf breaks DNS by removing /etc/resolv.conf. Bouncing + # where purging resolvconf breaks DNS by removing /etc/resolv.conf. Bouncing # the interface rebuilds it. + # The Ubuntu bug is: + # https://bugs.launchpad.net/ubuntu/+source/resolvconf/+bug/1593489 when: bounce_interface == "True" or (ansible_lsb.id|lower == 'ubuntu' and ansible_lsb.major_release|int >= 16) -- 2.39.5