summaryrefslogtreecommitdiffstats
path: root/ansible/roles/rke/molecule/default/destroy.yml
diff options
context:
space:
mode:
authorMichal Zegan <m.zegan@samsung.com>2019-04-30 14:52:13 +0200
committerMichal Zegan <m.zegan@samsung.com>2019-06-03 14:49:32 +0200
commit1ec19b0598382aa45258ed630ee26cba4fb3a7e5 (patch)
tree795a6486f4d40a1890a79e65a0afad6397c44d3e /ansible/roles/rke/molecule/default/destroy.yml
parent82052ddde7b2896c05c7b930d8e09d582025f0b3 (diff)
Add molecule tests for rke role
This change adds molecule tests for the rke role, and modifies the rke role itself to be more idempotent/to pass linter. Note that this molecule test case uses a separate role to install docker in containers, that runs docker daemon inside of them instead of using host docker. Issue-ID: OOM-1778 Change-Id: I875f3ff2ab961e5428acee5a02287a8d2d6e9969 Signed-off-by: Michal Zegan <m.zegan@samsung.com>
Diffstat (limited to 'ansible/roles/rke/molecule/default/destroy.yml')
-rw-r--r--ansible/roles/rke/molecule/default/destroy.yml34
1 files changed, 34 insertions, 0 deletions
diff --git a/ansible/roles/rke/molecule/default/destroy.yml b/ansible/roles/rke/molecule/default/destroy.yml
new file mode 100644
index 00000000..591da82e
--- /dev/null
+++ b/ansible/roles/rke/molecule/default/destroy.yml
@@ -0,0 +1,34 @@
+---
+- name: Destroy
+ hosts: localhost
+ connection: local
+ gather_facts: false
+ no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}"
+ tasks:
+ - name: Destroy molecule instance(s)
+ docker_container:
+ name: "{{ item.name }}"
+ docker_host: "{{ item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
+ state: absent
+ force_kill: "{{ item.force_kill | default(true) }}"
+ # Modification: we want to clean up old volumes.
+ keep_volumes: false
+ register: server
+ with_items: "{{ molecule_yml.platforms }}"
+ async: 7200
+ poll: 0
+
+ - name: Wait for instance(s) deletion to complete
+ async_status:
+ jid: "{{ item.ansible_job_id }}"
+ register: docker_jobs
+ until: docker_jobs.finished
+ retries: 300
+ with_items: "{{ server.results }}"
+
+ - name: Delete docker network(s)
+ docker_network:
+ name: "{{ item }}"
+ docker_host: "{{ item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
+ state: absent
+ with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}"