kayobe/ansible/roles/docker-registry/tasks/destroy.yml
Mark Goddard 7d7dc486a4 Fix destroy of opensm and docker-registry containers
Now also removes docker volumes
2017-08-22 15:12:05 +00:00

26 lines
667 B
YAML

---
- include: deploy.yml
- name: Check whether docker registry volumes are present
command: docker volume inspect {{ volume }}
changed_when: False
with_subelements:
- "{{ docker_registry_services }}"
- volumes
when: "'/' not in volume"
failed_when:
- volume_result.rc != 0
- "'No such volume' not in volume_result.stderr"
vars:
volume: "{{ item.1.split(':')[0] }}"
register: volume_result
- name: Ensure docker registry volumes are absent
command: docker volume rm {{ volume }}
with_items: "{{ volume_result.results }}"
when:
- not item | skipped
- item.rc == 0
vars:
volume: "{{ item.item.1.split(':')[0] }}"