mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-17 12:28:55 +00:00
Allowing anonymous volumes via mounts option (#181)
* Initial Commit * Adding changelog fragment
This commit is contained in:
parent
e2785de840
commit
b2430f756f
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- docker_container - lifted restriction preventing the creation of anonymous volumes with the ``mounts`` option
|
||||||
|
(https://github.com/ansible-collections/community.docker/pull/181).
|
||||||
@ -486,6 +486,7 @@ options:
|
|||||||
source:
|
source:
|
||||||
description:
|
description:
|
||||||
- Mount source (e.g. a volume name or a host path).
|
- Mount source (e.g. a volume name or a host path).
|
||||||
|
- If not supplied when I(type=volume) an anonymous volume will be created.
|
||||||
type: str
|
type: str
|
||||||
type:
|
type:
|
||||||
description:
|
description:
|
||||||
@ -2004,7 +2005,7 @@ class TaskParameters(DockerBaseClass):
|
|||||||
datatype = mount['type']
|
datatype = mount['type']
|
||||||
mount_dict = dict(mount)
|
mount_dict = dict(mount)
|
||||||
# Sanity checks (so we don't wait for docker-py to barf on input)
|
# Sanity checks (so we don't wait for docker-py to barf on input)
|
||||||
if mount_dict.get('source') is None and datatype != 'tmpfs':
|
if mount_dict.get('source') is None and datatype not in ('tmpfs', 'volume'):
|
||||||
self.client.fail('source must be specified for mount "{0}" of type "{1}"'.format(target, datatype))
|
self.client.fail('source must be specified for mount "{0}" of type "{1}"'.format(target, datatype))
|
||||||
mount_option_types = dict(
|
mount_option_types = dict(
|
||||||
volume_driver='volume',
|
volume_driver='volume',
|
||||||
|
|||||||
@ -119,6 +119,30 @@
|
|||||||
register: mounts_6
|
register: mounts_6
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: mounts (anonymous volume)
|
||||||
|
docker_container:
|
||||||
|
image: "{{ docker_test_image_alpine }}"
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
name: "{{ cname }}"
|
||||||
|
state: started
|
||||||
|
mounts:
|
||||||
|
- target: /tmp
|
||||||
|
type: volume
|
||||||
|
force_kill: true
|
||||||
|
register: mounts_7
|
||||||
|
|
||||||
|
- name: mounts (anonymous volume idempotency)
|
||||||
|
docker_container:
|
||||||
|
image: "{{ docker_test_image_alpine }}"
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
name: "{{ cname }}"
|
||||||
|
state: started
|
||||||
|
mounts:
|
||||||
|
- target: /tmp
|
||||||
|
type: volume
|
||||||
|
force_kill: true
|
||||||
|
register: mounts_8
|
||||||
|
|
||||||
- name: cleanup
|
- name: cleanup
|
||||||
docker_container:
|
docker_container:
|
||||||
name: "{{ cname }}"
|
name: "{{ cname }}"
|
||||||
@ -135,6 +159,8 @@
|
|||||||
- mounts_5 is changed
|
- mounts_5 is changed
|
||||||
- mounts_6 is failed
|
- mounts_6 is failed
|
||||||
- "'The mount point \"/x\" appears twice in the mounts option' == mounts_6.msg"
|
- "'The mount point \"/x\" appears twice in the mounts option' == mounts_6.msg"
|
||||||
|
- mounts_7 is changed
|
||||||
|
- mounts_8 is not changed
|
||||||
when: docker_py_version is version('2.6.0', '>=')
|
when: docker_py_version is version('2.6.0', '>=')
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user