Skip to content

Commit

Permalink
Add tasks to undo changes to hosts /etc/resolv.conf and dhclient configs
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Jan 11, 2017
1 parent 1191876 commit a7bf786
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
22 changes: 22 additions & 0 deletions roles/kubernetes/preinstall/tasks/dhclient-hooks-undo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---

# 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: Remove kargo specific config from dhclient config
blockinfile:
dest: "{{dhclientconffile}}"
state: absent
backup: yes
follow: yes
marker: "# Ansible entries {mark}"
notify: Preinstall | restart network

- name: Remove kargo specific dhclient hook
file: path="{{ dhclienthookfile }}" state=absent
notify: Preinstall | restart network
when: ansible_os_family != "RedHat"

# We need to make sure the network is restarted early enough so that docker can later pick up the correct system
# nameservers and search domains
- meta: flush_handlers
8 changes: 8 additions & 0 deletions roles/kubernetes/preinstall/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@
when: dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'
tags: [bootstrap-os, resolvconf]

- include: dhclient-hooks.yml
when: dns_mode != 'none' and resolvconf_mode == 'host_resolvconf' and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
tags: [bootstrap-os, resolvconf]

- include: dhclient-hooks-undo.yml
when: dns_mode != 'none' and resolvconf_mode != 'host_resolvconf' and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
tags: [bootstrap-os, resolvconf]

- name: Check if we are running inside a Azure VM
stat: path=/var/lib/waagent/
register: azure_check
Expand Down
4 changes: 0 additions & 4 deletions roles/kubernetes/preinstall/tasks/resolvconf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,3 @@
mode: 0644
notify: Preinstall | update resolvconf for Container Linux by CoreOS
when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]

- include: dhclient-hooks.yml
when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
tags: [bootstrap-os, resolvconf]

0 comments on commit a7bf786

Please sign in to comment.