From d5a366b5f68916d38d4bdc6938a3f92bcbc43dc6 Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Fri, 5 Feb 2016 20:17:28 +0000 Subject: [PATCH] Add a test for nmcli and also a blacklist var we can set on hosts that shouldn't have ifcfg managed by ansible. --- roles/base/tasks/main.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index 1a22e82e21..93050f56f2 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -20,11 +20,16 @@ - base - ifcfg +- name: check for NetworkManager/nmcli + command: /usr/bin/test -f /usr/bin/nmcli + register: nmclitest + ignore_errors: true + - name: disable resolv.conf control from NM ini_file: dest=/etc/NetworkManager/NetworkManager.conf section=main option=dns value=none notify: - restart NetworkManager - when: ansible_distribution_major_version|int >=7 + when: ansible_distribution_major_version|int >=7 and nmclitest|success and ansible_ifcfg_blacklist not defined tags: - config - resolvconf @@ -37,7 +42,7 @@ changed_when: false failed_when: 'if_uuid.stdout == ""' always_run: yes - when: ansible_distribution_major_version|int >=7 + when: ansible_distribution_major_version|int >=7 and nmclitest|success and ansible_ifcfg_blacklist not defined tags: - config - ifcfg @@ -51,7 +56,7 @@ # - restart NetworkManager - reload NetworkManager-connections - apply interface-changes - when: (virthost is not defined) and (not item.startswith('tun')) and (not item.startswith('virbr')) and (hostvars[inventory_hostname]['ansible_' + item.replace('-','_')]['type'] == 'ether') and (ansible_distribution_major_version|int >=7) and hostvars[inventory_hostname]['ansible_' + item.replace('-','_')]['active'] + when: (virthost is not defined) and (not item.startswith('tun')) and (not item.startswith('virbr')) and (hostvars[inventory_hostname]['ansible_' + item.replace('-','_')]['type'] == 'ether') and (ansible_distribution_major_version|int >=7) and hostvars[inventory_hostname]['ansible_' + item.replace('-','_')]['active'] and nmclitest|success and ansible_ifcfg_blacklist not defined tags: - config - ifcfg