openstack-helm-infra/tools/images/kubeadm-aio/assets/opt/playbooks/roles/clean-host/tasks/main.yaml

57 lines
1.7 KiB
YAML

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: clean | kube | remove config
file:
path: "{{ item }}"
state: absent
with_items:
- /etc/kubernetes
- name: clean | kube | stop kubelet service
ignore_errors: yes
systemd:
name: kubelet
state: stopped
enabled: no
masked: no
- name: clean | kube | removing any old docker containers
ignore_errors: yes
shell: MY_CONTAINER_ID=$(docker inspect --format {% raw %}'{{ .Id }}'{% endraw %} "{{ my_container_name }}"); docker ps --all --no-trunc --quiet | awk '!'"/${MY_CONTAINER_ID}/ { print \$1 }" | xargs -r -l1 -P16 docker rm -f
- name: clean | kube | remove any mounts
ignore_errors: yes
shell: |-
for MOUNT in $(findmnt --df --output TARGET | grep "^/var/lib/kubelet"); do
umount --force $MOUNT
done
- name: clean | kube | remove dirs
file:
path: "{{ item }}"
state: absent
with_items:
- /etc/kubernetes
- /etc/cni/net.d
- /etc/systemd/system/kubelet.service
- /etc/systemd/system/kubelet.service.d
- /var/lib/kubelet
- /var/lib/etcd
- /var/etcd
- /opt/cni/bin
- name: clean | kube | reload systemd
systemd:
daemon_reload: yes