blob: 21b0298881cd10f34d9bfc13d12e3804c535fcd9 [file] [log] [blame]
Bartek Grzybowskiee157b52019-04-26 13:26:45 +02001---
2# Remove containers spawned by Rancher Agent
3- name: Get list of containers spawned by Rancher Agent
4 docker_list_containers:
5 label_name: "{{ item.label }}"
6 label_value: "{{ item.value }}"
7 loop: "{{ container_list_by_label }}"
8 register: docker_list_containers_var
9
10- name: set fact # save a list of containers found by previous task to orphaned_containers var
11 set_fact: orphaned_containers="{{ orphaned_containers|default([]) + item.containers }}"
12 loop: "{{ docker_list_containers_var.results }}"
13
14- name: Remove orphaned containers
15 docker_container:
16 name: "{{ item }}"
17 state: absent
18 loop: "{{ orphaned_containers }}"