Ansible: Fix cleanup procedures 27/30427/4
authorpmikus <pmikus@cisco.com>
Tue, 15 Dec 2020 16:33:46 +0000 (16:33 +0000)
committerPeter Mikus <pmikus@cisco.com>
Thu, 17 Dec 2020 09:32:19 +0000 (09:32 +0000)
Signed-off-by: pmikus <pmikus@cisco.com>
Change-Id: Ib0c3a508b32a4d5929cfc20a7a7813752350b7d9

resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_containers.yaml
resources/tools/testbed-setup/ansible/roles/cleanup/tasks/kill_process.yaml
resources/tools/testbed-setup/ansible/roles/cleanup/tasks/sut.yaml

index 1cd6435..ad4fb37 100644 (file)
@@ -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
index a593fc7..30a9f45 100644 (file)
@@ -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!"
index c24b5e6..53a65dd 100644 (file)
         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:

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.