diff options
Diffstat (limited to 'ansible/test/roles')
-rw-r--r-- | ansible/test/roles/cleanup-rancher/tasks/main.yml | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ansible/test/roles/cleanup-rancher/tasks/main.yml b/ansible/test/roles/cleanup-rancher/tasks/main.yml new file mode 100644 index 00000000..21b02988 --- /dev/null +++ b/ansible/test/roles/cleanup-rancher/tasks/main.yml @@ -0,0 +1,18 @@ +--- +# Remove containers spawned by Rancher Agent +- name: Get list of containers spawned by Rancher Agent + docker_list_containers: + label_name: "{{ item.label }}" + label_value: "{{ item.value }}" + loop: "{{ container_list_by_label }}" + register: docker_list_containers_var + +- name: set fact # save a list of containers found by previous task to orphaned_containers var + set_fact: orphaned_containers="{{ orphaned_containers|default([]) + item.containers }}" + loop: "{{ docker_list_containers_var.results }}" + +- name: Remove orphaned containers + docker_container: + name: "{{ item }}" + state: absent + loop: "{{ orphaned_containers }}" |