Merge pull request #1239 from mattymo/resettags

Add tags to reset playbook and make iptables flush optional
This commit is contained in:
Matthew Mosesohn 2017-04-20 11:35:08 +03:00 committed by GitHub
commit f04e3615f4
2 changed files with 16 additions and 0 deletions

View file

@ -0,0 +1,2 @@
---
flush_iptables: true

View file

@ -8,6 +8,7 @@
- kubelet - kubelet
- etcd - etcd
failed_when: false failed_when: false
tags: ['services']
- name: reset | remove services - name: reset | remove services
file: file:
@ -17,6 +18,7 @@
- kubelet - kubelet
- etcd - etcd
register: services_removed register: services_removed
tags: ['services']
- name: reset | remove docker dropins - name: reset | remove docker dropins
file: file:
@ -26,6 +28,7 @@
- docker-dns.conf - docker-dns.conf
- docker-options.conf - docker-options.conf
register: docker_dropins_removed register: docker_dropins_removed
tags: ['docker']
- name: reset | systemctl daemon-reload - name: reset | systemctl daemon-reload
command: systemctl daemon-reload command: systemctl daemon-reload
@ -33,25 +36,31 @@
- name: reset | remove all containers - name: reset | remove all containers
shell: "{{ docker_bin_dir }}/docker ps -aq | xargs -r docker rm -fv" shell: "{{ docker_bin_dir }}/docker ps -aq | xargs -r docker rm -fv"
tags: ['docker']
- name: reset | restart docker if needed - name: reset | restart docker if needed
service: service:
name: docker name: docker
state: restarted state: restarted
when: docker_dropins_removed.changed when: docker_dropins_removed.changed
tags: ['docker']
- name: reset | gather mounted kubelet dirs - name: reset | gather mounted kubelet dirs
shell: mount | grep /var/lib/kubelet | awk '{print $3}' | tac shell: mount | grep /var/lib/kubelet | awk '{print $3}' | tac
check_mode: no check_mode: no
register: mounted_dirs register: mounted_dirs
tags: ['mounts']
- name: reset | unmount kubelet dirs - name: reset | unmount kubelet dirs
command: umount {{item}} command: umount {{item}}
with_items: '{{ mounted_dirs.stdout_lines }}' with_items: '{{ mounted_dirs.stdout_lines }}'
tags: ['mounts']
- name: flush iptables - name: flush iptables
iptables: iptables:
flush: yes flush: yes
when: flush_iptables|bool
tags: ['iptables']
- name: reset | delete some files and directories - name: reset | delete some files and directories
file: file:
@ -74,6 +83,8 @@
- /etc/dhcp/dhclient.d/zdnsupdate.sh - /etc/dhcp/dhclient.d/zdnsupdate.sh
- /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate - /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
- "{{ bin_dir }}/kubelet" - "{{ bin_dir }}/kubelet"
tags: ['files']
- name: reset | remove dns settings from dhclient.conf - name: reset | remove dns settings from dhclient.conf
blockinfile: blockinfile:
@ -85,6 +96,7 @@
with_items: with_items:
- /etc/dhclient.conf - /etc/dhclient.conf
- /etc/dhcp/dhclient.conf - /etc/dhcp/dhclient.conf
tags: ['files', 'dns']
- name: reset | remove host entries from /etc/hosts - name: reset | remove host entries from /etc/hosts
blockinfile: blockinfile:
@ -92,6 +104,7 @@
state: absent state: absent
follow: yes follow: yes
marker: "# Ansible inventory hosts {mark}" marker: "# Ansible inventory hosts {mark}"
tags: ['files', 'dns']
- name: reset | Restart network - name: reset | Restart network
service: service:
@ -103,3 +116,4 @@
{%- endif %} {%- endif %}
state: restarted state: restarted
when: ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"] when: ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"]
tags: ['services', 'network']