aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2020-12-15 16:33:46 +0000
committerPeter Mikus <pmikus@cisco.com>2020-12-17 09:32:19 +0000
commitd513fb2ae6cba746b9e4456c544668a07b5d40f2 (patch)
treea42b62ea9eb35c22958ea0a8a27b3f63d8de0fac
parentd910b96c6e5215f0d8961c121f086cd3c2703e43 (diff)
Ansible: Fix cleanup procedures
Signed-off-by: pmikus <pmikus@cisco.com> Change-Id: Ib0c3a508b32a4d5929cfc20a7a7813752350b7d9
-rw-r--r--resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_containers.yaml21
-rw-r--r--resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_process.yaml1
-rw-r--r--resources/tools/testbed-setup/ansible/roles/cleanup/tasks/sut.yaml24
3 files changed, 34 insertions, 12 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
diff --git a/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_process.yaml b/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_process.yaml
index a593fc7616..30a9f459b5 100644
--- a/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_process.yaml
+++ b/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_process.yaml
@@ -27,6 +27,7 @@
shell: "kill -9 {{ item }}"
with_items: "{{ killed_processes.results | select('failed') | map(attribute='item') | list }}"
tags: kill-process
+
rescue:
- fail:
msg: "Kill process {{ process }} failed!"
diff --git a/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/sut.yaml b/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/sut.yaml
index c24b5e6a7f..53a65dd608 100644
--- a/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/sut.yaml
+++ b/resources/tools/testbed-setup/ansible/roles/cleanup/tasks/sut.yaml
@@ -33,26 +33,38 @@
process: "vpp_echo"
tags: kill-process
+ - name: Find file or dir - Core zip file
+ find:
+ paths: "/tmp/"
+ patterns: "*tar.lzo.lrz.xz*"
+ register: files_to_delete
+ tags: remove-file-dir
+
- name: Remove file or dir - Core zip file
file:
+ path: "{{ item.path }}"
state: absent
- path: "/tmp/*tar.lzo.lrz.xz*"
+ with_items: "{{ files_to_delete.files }}"
+ tags: remove-file-dir
+
+ - name: Find file or dir - Core dump file
+ find:
+ paths: "/tmp/"
+ patterns: "*core*"
+ register: files_to_delete
tags: remove-file-dir
- name: Remove file or dir - Core dump file
file:
+ path: "{{ item.path }}"
state: absent
- path: "/tmp/*core*"
+ with_items: "{{ files_to_delete.files }}"
tags: remove-file-dir
- name: Kill containers - Remove all containers
import_tasks: kill_containers.yaml
tags: kill-containers
- - name: Kubernetes - Reset
- raw: 'kubeadm reset --force'
- tags: kill-kubernetes
-
- name: Remove packages - Remove VPP
import_tasks: remove_package.yaml
vars: