diff options
author | 2020-12-15 16:33:46 +0000 | |
---|---|---|
committer | 2020-12-17 09:32:19 +0000 | |
commit | d513fb2ae6cba746b9e4456c544668a07b5d40f2 (patch) | |
tree | a42b62ea9eb35c22958ea0a8a27b3f63d8de0fac /resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_containers.yaml | |
parent | d910b96c6e5215f0d8961c121f086cd3c2703e43 (diff) |
Ansible: Fix cleanup procedures
Signed-off-by: pmikus <pmikus@cisco.com>
Change-Id: Ib0c3a508b32a4d5929cfc20a7a7813752350b7d9
Diffstat (limited to 'resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_containers.yaml')
-rw-r--r-- | resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_containers.yaml | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_containers.yaml b/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_containers.yaml index 1cd64351a8..ad4fb37681 100644 --- a/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_containers.yaml +++ b/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_containers.yaml @@ -1,29 +1,38 @@ --- # file: roles/cleanup/tasks/kill_containers.yaml -- name: Kill containers +- name: Kill Docker Containers block: - - name: Kill container - Get running Docker containers + - name: Kill container - Get Running Docker Containers shell: "docker ps -aq" register: running_containers changed_when: no tags: kill-containers - - name: Kill container - Remove all Docker containers + - name: Kill container - Remove All Docker Containers shell: "docker rm --force {{ item }}" with_items: "{{ running_containers.stdout_lines }}" tags: kill-containers - - name: Kill container - Get running LXC containers + rescue: + - name: Restart Docker Daemon + systemd: + name: "docker" + state: "restarted" + +- name: Kill LXC Containers + block: + - name: Kill container - Get Running LXC Containers shell: "lxc-ls" register: running_containers changed_when: no tags: kill-containers - - name: Kill container - Remove all LXC containers + - name: Kill container - Remove All LXC Containers shell: "lxc-destroy --force -n {{ item }}" with_items: "{{ running_containers.stdout_lines }}" tags: kill-containers + rescue: - fail: - msg: "Kill containers failed!" + msg: "Kill LXC containers failed!"
\ No newline at end of file |