kayobe/ansible/roles/opensm/tasks/destroy.yml
Will Szumski 27ece2622b Fix issue removing docker volumes
The error response from the docker daemon has changed to:

    Error response from daemon: get opensm_logs: no such volume

This change should support both old and new responses.

Change-Id: Ibef1713d7de2e0a2c6fe046f607b2a8e60dae3da
Closes-Bug: #2050092
2024-05-21 12:59:22 +02:00

30 lines
791 B
YAML

---
- name: Ensure OpenSM container is stopped
docker_container:
name: "{{ item.value.container_name }}"
state: "absent"
with_dict: "{{ opensm_services }}"
- name: Check whether OpenSM volumes are present
command: docker volume inspect {{ volume }}
changed_when: False
with_subelements:
- "{{ opensm_services }}"
- volumes
when: "'/' not in volume"
failed_when:
- volume_result.rc != 0
- "'no such volume' not in volume_result.stderr | lower"
vars:
volume: "{{ item.1.split(':')[0] }}"
register: volume_result
- name: Ensure OpenSM volumes are absent
command: docker volume rm {{ volume }}
with_items: "{{ volume_result.results }}"
when:
- item is not skipped
- item.rc == 0
vars:
volume: "{{ item.item.1.split(':')[0] }}"