From 923057c1a83531eb8a50a00a416d4768c14577b2 Mon Sep 17 00:00:00 2001 From: Greg Althaus Date: Fri, 13 Jan 2017 10:14:57 -0600 Subject: [PATCH] This continues the DHCP hook checks. Also protect the create side if the system doesn't have any config files at all. --- roles/kubernetes/preinstall/tasks/dhclient-hooks-undo.yml | 6 +----- roles/kubernetes/preinstall/tasks/dhclient-hooks.yml | 1 + roles/kubernetes/preinstall/tasks/set_resolv_facts.yml | 6 +++++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/roles/kubernetes/preinstall/tasks/dhclient-hooks-undo.yml b/roles/kubernetes/preinstall/tasks/dhclient-hooks-undo.yml index afab236df..f233f4c1d 100644 --- a/roles/kubernetes/preinstall/tasks/dhclient-hooks-undo.yml +++ b/roles/kubernetes/preinstall/tasks/dhclient-hooks-undo.yml @@ -3,10 +3,6 @@ # These tasks will undo changes done by kargo in the past if needed (e.g. when upgrading from kargo 2.0.x # or when changing resolvconf_mode) -- name: Check if dhclient conf file exists - stat: path={{dhclientconffile}} - register: dhclientconf_check - - name: Remove kargo specific config from dhclient config blockinfile: dest: "{{dhclientconffile}}" @@ -14,7 +10,7 @@ backup: yes follow: yes marker: "# Ansible entries {mark}" - when: dhclientconf_check.stat.exists + when: dhclientconffile is defined notify: Preinstall | restart network - name: Remove kargo specific dhclient hook diff --git a/roles/kubernetes/preinstall/tasks/dhclient-hooks.yml b/roles/kubernetes/preinstall/tasks/dhclient-hooks.yml index a574ea1e7..8c0a5f599 100644 --- a/roles/kubernetes/preinstall/tasks/dhclient-hooks.yml +++ b/roles/kubernetes/preinstall/tasks/dhclient-hooks.yml @@ -13,6 +13,7 @@ follow: yes marker: "# Ansible entries {mark}" notify: Preinstall | restart network + when: dhclientconffile is defined - name: Configue dhclient hooks for resolv.conf (non-RH) template: diff --git a/roles/kubernetes/preinstall/tasks/set_resolv_facts.yml b/roles/kubernetes/preinstall/tasks/set_resolv_facts.yml index a2e97b819..81db5a34e 100644 --- a/roles/kubernetes/preinstall/tasks/set_resolv_facts.yml +++ b/roles/kubernetes/preinstall/tasks/set_resolv_facts.yml @@ -50,10 +50,14 @@ dhclientconffile: /etc/dhclient.conf when: dhclient_stat.stat.exists +- name: check if /etc/dhcp/dhclient.conf exists + stat: path=/etc/dhcp/dhclient.conf + register: dhcp_dhclient_stat + - name: target dhclient conf file for /etc/dhcp/dhclient.conf set_fact: dhclientconffile: /etc/dhcp/dhclient.conf - when: not dhclient_stat.stat.exists + when: dhcp_dhclient_stat.stat.exists - name: target dhclient hook file for Red Hat family set_fact: