fix 清理脚本容器目录无法删除问题

pull/971/head
gjmzj 2021-01-11 12:59:29 +08:00
parent b9da653b04
commit b7a6d1705f
2 changed files with 29 additions and 12 deletions

View File

@ -39,16 +39,35 @@
ignore_errors: true ignore_errors: true
# as k8s-network-plugins use host-network, '/var/run/docker/netns/default' must be umounted # as k8s-network-plugins use host-network, '/var/run/docker/netns/default' must be umounted
- name: unmount docker filesystem-1 - name: umount docker filesystem-1
mount: path=/var/run/docker/netns/default state=unmounted mount: path=/var/run/docker/netns/default state=unmounted
- name: unmount docker filesystem-2 - name: umount docker filesystem-2
mount: path=/var/lib/docker/overlay state=unmounted mount: path=/var/lib/docker/overlay state=unmounted
- name: umount docker filesystem-3
shell: "echo /var/lib/docker/overlay2/*/merged|xargs umount || exit 0"
args:
warn: false
ignore_errors: true
- name: umount docker filesystem-4
shell: "echo /var/lib/docker/containers/*/mounts/shm|xargs umount || exit 0"
args:
warn: false
ignore_errors: true
- name: umount docker filesystem-5
shell: "echo /var/run/docker/netns/*|xargs umount || exit 0"
args:
warn: false
ignore_errors: true
- name: remove files and dirs - name: remove files and dirs
file: name={{ item }} state=absent file: name={{ item }} state=absent
with_items: with_items:
- "/var/lib/docker/" - "/var/lib/docker/"
- "/var/lib/dockershim/"
- "/var/run/docker/" - "/var/run/docker/"
- "/etc/docker/" - "/etc/docker/"
- "/etc/systemd/system/docker.service" - "/etc/systemd/system/docker.service"
@ -57,6 +76,7 @@
- "/etc/bash_completion.d/docker" - "/etc/bash_completion.d/docker"
- "/usr/bin/docker" - "/usr/bin/docker"
when: "'kubeasz' not in install_info.stdout" when: "'kubeasz' not in install_info.stdout"
ignore_errors: true
when: CONTAINER_RUNTIME == 'docker' when: CONTAINER_RUNTIME == 'docker'
- block: - block:
@ -82,6 +102,7 @@
- "/opt/containerd/" - "/opt/containerd/"
- "/var/lib/containerd/" - "/var/lib/containerd/"
- "/var/run/containerd/" - "/var/run/containerd/"
ignore_errors: true
when: CONTAINER_RUNTIME == 'containerd' when: CONTAINER_RUNTIME == 'containerd'
- name: remove files and dirs2 - name: remove files and dirs2
@ -104,10 +125,6 @@
- "/etc/origin/openvswitch/" - "/etc/origin/openvswitch/"
- "/etc/openvswitch/" - "/etc/openvswitch/"
- "/var/log/openvswitch/" - "/var/log/openvswitch/"
- "/var/run/ovn/"
- "/etc/origin/ovn/"
- "/etc/ovn/"
- "/var/log/ovn/"
# - name: cleanup networks1 # - name: cleanup networks1
# shell: "ip link del tunl0; \ # shell: "ip link del tunl0; \

View File

@ -1,13 +1,13 @@
# #
- import_tasks: clean_etcd.yml
when: 'DEL_ETCD == "yes"'
- import_tasks: clean_master.yml - import_tasks: clean_master.yml
when: 'DEL_MASTER == "yes"' when: 'DEL_MASTER == "yes"'
- import_tasks: clean_node.yml - import_tasks: clean_node.yml
when: 'DEL_NODE == "yes"' when: 'DEL_NODE == "yes"'
- import_tasks: clean_etcd.yml
when: 'DEL_ETCD == "yes"'
- import_tasks: clean_lb.yml - import_tasks: clean_lb.yml
when: 'DEL_LB == "yes"' when: 'DEL_LB == "yes"'