ansible/test/integration/targets/docker_volume_facts/tasks/main.yml
Felix Fontein 89a1c68f98 docker_volume: improve force option (deprecate, add new option) (#51145)
* docker_volume: Deprecating force option, adding recreate option.

* Add changelog.

* Remove mis-placed force: yes for docker_volume.
2019-02-03 15:09:24 -05:00

58 lines
1.7 KiB
YAML

---
- block:
- name: Create random volume name
set_fact:
cname: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
- name: Make sure volume is not there
docker_volume:
name: "{{ cname }}"
state: absent
- name: Inspect a non-present volume
docker_volume_facts:
name: "{{ cname }}"
register: result
- assert:
that:
- "not result.exists"
- "'docker_volume' in result"
- "result.docker_volume is none"
- name: Make sure volume exists
docker_volume:
name: "{{ cname }}"
- name: Inspect a present volume
docker_volume_facts:
name: "{{ cname }}"
register: result
- name: Dump docker_volume_facts result
debug: var=result
- name: "Comparison: use 'docker volume inspect'"
command: docker volume inspect "{{ cname }}"
register: docker_volume_inspect
- set_fact:
docker_volume_inspect_result: "{{ docker_volume_inspect.stdout | from_json }}"
- name: Dump docker volume inspect result
debug: var=docker_volume_inspect_result
- name: Cleanup
docker_volume:
name: "{{ cname }}"
state: absent
- assert:
that:
- result.exists
- "'docker_volume' in result"
- "result.docker_volume"
- "result.docker_volume == docker_volume_inspect_result[0]"
# Requirements for docker_volume
when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.24', '>=')
- fail: msg="Too old docker / docker-py version to run docker_volume_facts tests!"
when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.24', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)