docker_swarm_service: Added default value for mounts.source (#58039)
* Added default value for mounts.source * Added the changelog fragment * Added tests * Fixed separators * Moved the teardown section at the end
This commit is contained in:
parent
4188cd299b
commit
122d4164c5
3 changed files with 50 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- docker_swarm_service - fix resource lookup if mounts.source="".
|
|
@ -2230,7 +2230,7 @@ class DockerServiceManager(object):
|
||||||
(key.lower(), value) for key, value in driver_config.items()
|
(key.lower(), value) for key, value in driver_config.items()
|
||||||
) or None
|
) or None
|
||||||
ds.mounts.append({
|
ds.mounts.append({
|
||||||
'source': mount_data['Source'],
|
'source': mount_data.get('Source', ''),
|
||||||
'type': mount_data['Type'],
|
'type': mount_data['Type'],
|
||||||
'target': mount_data['Target'],
|
'target': mount_data['Target'],
|
||||||
'readonly': mount_data.get('ReadOnly'),
|
'readonly': mount_data.get('ReadOnly'),
|
||||||
|
|
|
@ -509,6 +509,53 @@
|
||||||
- "'Minimum version required' in mounts_tmpfs_size_1.msg"
|
- "'Minimum version required' in mounts_tmpfs_size_1.msg"
|
||||||
when: docker_py_version is version('2.6.0', '<')
|
when: docker_py_version is version('2.6.0', '<')
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
## mounts.source ###################################################
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
- name: mounts.source (empty for tmpfs)
|
||||||
|
docker_swarm_service:
|
||||||
|
name: "{{ service_name }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
resolve_image: no
|
||||||
|
command: '/bin/sh -v -c "sleep 10m"'
|
||||||
|
mounts:
|
||||||
|
- source: ""
|
||||||
|
target: "/tmp/{{ volume_name_1 }}"
|
||||||
|
type: "tmpfs"
|
||||||
|
register: mounts_tmpfs_source_1
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: mounts.source (empty for tmpfs idempotency)
|
||||||
|
docker_swarm_service:
|
||||||
|
name: "{{ service_name }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
resolve_image: no
|
||||||
|
command: '/bin/sh -v -c "sleep 10m"'
|
||||||
|
mounts:
|
||||||
|
- source: ""
|
||||||
|
target: "/tmp/{{ volume_name_1 }}"
|
||||||
|
type: "tmpfs"
|
||||||
|
register: mounts_tmpfs_source_2
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: cleanup
|
||||||
|
docker_swarm_service:
|
||||||
|
name: "{{ service_name }}"
|
||||||
|
state: absent
|
||||||
|
diff: no
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- mounts_tmpfs_source_1 is changed
|
||||||
|
- mounts_tmpfs_source_2 is not changed
|
||||||
|
when: docker_py_version is version('2.6.0', '>=')
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- mounts_tmpfs_source_1 is failed
|
||||||
|
- "'Minimum version required' in mounts_tmpfs_source_1.msg"
|
||||||
|
when: docker_py_version is version('2.6.0', '<')
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
####################################################################
|
####################################################################
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|
Loading…
Reference in a new issue