blob: 591da82eee7576ef547550d80548d9fe78d5e825 [file] [log] [blame]
Michal Zegan1ec19b02019-04-30 14:52:13 +02001---
2- name: Destroy
3 hosts: localhost
4 connection: local
5 gather_facts: false
6 no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}"
7 tasks:
8 - name: Destroy molecule instance(s)
9 docker_container:
10 name: "{{ item.name }}"
11 docker_host: "{{ item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
12 state: absent
13 force_kill: "{{ item.force_kill | default(true) }}"
14 # Modification: we want to clean up old volumes.
15 keep_volumes: false
16 register: server
17 with_items: "{{ molecule_yml.platforms }}"
18 async: 7200
19 poll: 0
20
21 - name: Wait for instance(s) deletion to complete
22 async_status:
23 jid: "{{ item.ansible_job_id }}"
24 register: docker_jobs
25 until: docker_jobs.finished
26 retries: 300
27 with_items: "{{ server.results }}"
28
29 - name: Delete docker network(s)
30 docker_network:
31 name: "{{ item }}"
32 docker_host: "{{ item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
33 state: absent
34 with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}"