community.docker/tests/integration/targets/docker_volume_info/tasks/main.yml
Felix Fontein a4539a309e
Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml (#430)
* Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml.

* ignore.txt lines cannot be empty or contain only a comment.

* Cleanup.

* This particular __init__.py seems to be crucial.

* Try extra newline.

* Markdown comments are a real mess. I hope this won't break Galaxy...

* More licenses.

* Add sanity test.

* Skip some files, lint.

* Make sure there is a copyright line everywhere.

* Also check for copyright line in sanity tests.

* Remove colon after 'Copyright'.

* Normalize lint script.

* Avoid colon after 'Copyright' in lint script.

* Improve license checker.

* Update README.md

Co-authored-by: Maxwell G <9920591+gotmax23@users.noreply.github.com>

* Remove superfluous space.

* Referencing target instead of symlink

Co-authored-by: Maxwell G <9920591+gotmax23@users.noreply.github.com>
2022-07-20 07:45:33 +02:00

78 lines
2.3 KiB
YAML

---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- block:
- name: Create random volume name
set_fact:
cname: "{{ 'ansible-docker-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_info:
name: "{{ cname }}"
register: result
- assert:
that:
- "not result.exists"
- "'volume' in result"
- "result.volume is none"
- name: Make sure volume exists
docker_volume:
name: "{{ cname }}"
- name: Inspect a present volume
docker_volume_info:
name: "{{ cname }}"
register: result
- name: Dump docker_volume_info result
debug: var=result
- name: "Comparison: use 'docker volume inspect'"
command: docker volume inspect "{{ cname }}"
register: docker_volume_inspect
ignore_errors: yes
- block:
- set_fact:
docker_volume_inspect_result: "{{ docker_volume_inspect.stdout | from_json }}"
- name: Dump docker volume inspect result
debug: var=docker_volume_inspect_result
when: docker_volume_inspect is not failed
- name: Cleanup
docker_volume:
name: "{{ cname }}"
state: absent
- assert:
that:
- result.exists
- "'volume' in result"
- "result.volume"
- assert:
that:
- "result.volume == docker_volume_inspect_result[0]"
when: docker_volume_inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in docker_volume_inspect.stderr"
when: docker_volume_inspect is failed
when: docker_api_version is version('1.25', '>=')
- fail: msg="Too old docker / docker-py version to run docker_volume_info tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)