From be224664893374bdedd5efe1209307ee8e55d983 Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Tue, 18 Apr 2017 17:15:22 +0300 Subject: [PATCH] Add tags to reset playbook and make iptables flush optional Fixes #1229 --- roles/reset/defaults/main.yml | 2 ++ roles/reset/tasks/main.yml | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 roles/reset/defaults/main.yml diff --git a/roles/reset/defaults/main.yml b/roles/reset/defaults/main.yml new file mode 100644 index 000000000..7d4dbfdff --- /dev/null +++ b/roles/reset/defaults/main.yml @@ -0,0 +1,2 @@ +--- +flush_iptables: true diff --git a/roles/reset/tasks/main.yml b/roles/reset/tasks/main.yml index f5f749647..96984f92b 100644 --- a/roles/reset/tasks/main.yml +++ b/roles/reset/tasks/main.yml @@ -8,6 +8,7 @@ - kubelet - etcd failed_when: false + tags: ['services'] - name: reset | remove services file: @@ -17,6 +18,7 @@ - kubelet - etcd register: services_removed + tags: ['services'] - name: reset | remove docker dropins file: @@ -26,6 +28,7 @@ - docker-dns.conf - docker-options.conf register: docker_dropins_removed + tags: ['docker'] - name: reset | systemctl daemon-reload command: systemctl daemon-reload @@ -33,25 +36,31 @@ - name: reset | remove all containers shell: "{{ docker_bin_dir }}/docker ps -aq | xargs -r docker rm -fv" + tags: ['docker'] - name: reset | restart docker if needed service: name: docker state: restarted when: docker_dropins_removed.changed + tags: ['docker'] - name: reset | gather mounted kubelet dirs shell: mount | grep /var/lib/kubelet | awk '{print $3}' | tac check_mode: no register: mounted_dirs + tags: ['mounts'] - name: reset | unmount kubelet dirs command: umount {{item}} with_items: '{{ mounted_dirs.stdout_lines }}' + tags: ['mounts'] - name: flush iptables iptables: flush: yes + when: flush_iptables|bool + tags: ['iptables'] - name: reset | delete some files and directories file: @@ -74,6 +83,8 @@ - /etc/dhcp/dhclient.d/zdnsupdate.sh - /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate - "{{ bin_dir }}/kubelet" + tags: ['files'] + - name: reset | remove dns settings from dhclient.conf blockinfile: @@ -85,6 +96,7 @@ with_items: - /etc/dhclient.conf - /etc/dhcp/dhclient.conf + tags: ['files', 'dns'] - name: reset | remove host entries from /etc/hosts blockinfile: @@ -92,6 +104,7 @@ state: absent follow: yes marker: "# Ansible inventory hosts {mark}" + tags: ['files', 'dns'] - name: reset | Restart network service: @@ -103,3 +116,4 @@ {%- endif %} state: restarted when: ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"] + tags: ['services', 'network']