docker_swarm_service: Set minimum docker-py version to 2.0.2 (#53295)

* Fix version checks in tests

* Set minimum version to 2.0.2

* Networks can only be updated >= docker-py 2.7

* Constraints require docker-py 2.4.0

* Healthchecks require docker-py 2.6.0

* Properly run tests different docker_py_versions

* Add changelog fragment

* Specify lowest version on placement.constraints

* Fix running new tests on older docker-py

* Handle different hosts formats returned by docker

* FIx test naming

* Quote str options

* secrets options require docker-py 2.4.0
This commit is contained in:
Hannes Ljungberg 2019-03-06 21:50:05 +01:00 committed by John R Barker
parent 5da0de0475
commit c563caf451
8 changed files with 325 additions and 164 deletions

View file

@ -0,0 +1,4 @@
bugfixes:
- "docker_swarm_service - Raise minimum required docker-py version for module to 2.0.2."
- "docker_swarm_service - Raise minimum required docker-py version for ``secrets`` to 2.4.0."
- "docker_swarm_service - Validate minimum docker-py version of 2.4.0 for option ``constraints``."

View file

@ -658,7 +658,7 @@ extends_documentation_fragment:
- docker - docker
- docker.docker_py_2_documentation - docker.docker_py_2_documentation
requirements: requirements:
- "docker >= 2.0" - "docker >= 2.0.2"
- "Docker API >= 1.24" - "Docker API >= 1.24"
notes: notes:
- "Images will only resolve to the latest digest when using Docker API >= 1.30 and docker-py >= 3.2.0. - "Images will only resolve to the latest digest when using Docker API >= 1.30 and docker-py >= 3.2.0.
@ -1784,7 +1784,12 @@ class DockerServiceManager(object):
hosts = task_template_data['ContainerSpec'].get('Hosts') hosts = task_template_data['ContainerSpec'].get('Hosts')
if hosts: if hosts:
hosts = [host.split(' ', 1) for host in hosts] hosts = [
list(reversed(host.split(":", 1)))
if ":" in host
else host.split(" ", 1)
for host in hosts
]
ds.hosts = dict((hostname, ip) for ip, hostname in hosts) ds.hosts = dict((hostname, ip) for ip, hostname in hosts)
ds.tty = task_template_data['ContainerSpec'].get('TTY') ds.tty = task_template_data['ContainerSpec'].get('TTY')
@ -1943,7 +1948,10 @@ class DockerServiceManager(object):
def can_update_networks(self): def can_update_networks(self):
# Before Docker API 1.29 adding/removing networks was not supported # Before Docker API 1.29 adding/removing networks was not supported
return self.client.docker_api_version >= LooseVersion('1.29') return (
self.client.docker_api_version >= LooseVersion('1.29') and
self.client.docker_py_version >= LooseVersion('2.7')
)
def run(self): def run(self):
self.diff_tracker = DifferenceTracker() self.diff_tracker = DifferenceTracker()
@ -2197,17 +2205,18 @@ def main():
) )
option_minimal_versions = dict( option_minimal_versions = dict(
constraints=dict(docker_py_version='2.4.0'),
dns=dict(docker_py_version='2.6.0', docker_api_version='1.25'), dns=dict(docker_py_version='2.6.0', docker_api_version='1.25'),
dns_options=dict(docker_py_version='2.6.0', docker_api_version='1.25'), dns_options=dict(docker_py_version='2.6.0', docker_api_version='1.25'),
dns_search=dict(docker_py_version='2.6.0', docker_api_version='1.25'), dns_search=dict(docker_py_version='2.6.0', docker_api_version='1.25'),
endpoint_mode=dict(docker_py_version='3.0.0', docker_api_version='1.25'), endpoint_mode=dict(docker_py_version='3.0.0', docker_api_version='1.25'),
force_update=dict(docker_py_version='2.1.0', docker_api_version='1.25'), force_update=dict(docker_py_version='2.1.0', docker_api_version='1.25'),
healthcheck=dict(docker_py_version='2.0.0', docker_api_version='1.25'), healthcheck=dict(docker_py_version='2.6.0', docker_api_version='1.25'),
hostname=dict(docker_py_version='2.2.0', docker_api_version='1.25'), hostname=dict(docker_py_version='2.2.0', docker_api_version='1.25'),
hosts=dict(docker_py_version='2.6.0', docker_api_version='1.25'), hosts=dict(docker_py_version='2.6.0', docker_api_version='1.25'),
groups=dict(docker_py_version='2.6.0', docker_api_version='1.25'), groups=dict(docker_py_version='2.6.0', docker_api_version='1.25'),
tty=dict(docker_py_version='2.4.0', docker_api_version='1.25'), tty=dict(docker_py_version='2.4.0', docker_api_version='1.25'),
secrets=dict(docker_py_version='2.1.0', docker_api_version='1.25'), secrets=dict(docker_py_version='2.4.0', docker_api_version='1.25'),
configs=dict(docker_py_version='2.6.0', docker_api_version='1.30'), configs=dict(docker_py_version='2.6.0', docker_api_version='1.30'),
update_max_failure_ratio=dict(docker_py_version='2.1.0', docker_api_version='1.25'), update_max_failure_ratio=dict(docker_py_version='2.1.0', docker_api_version='1.25'),
update_monitor=dict(docker_py_version='2.1.0', docker_api_version='1.25'), update_monitor=dict(docker_py_version='2.1.0', docker_api_version='1.25'),
@ -2259,6 +2268,13 @@ def main():
) is not None, ) is not None,
usage_msg='set placement.preferences' usage_msg='set placement.preferences'
), ),
placement_config_constraints=dict(
docker_py_version='2.4.0',
detect_usage=lambda c: (c.module.params['placement'] or {}).get(
'constraints'
) is not None,
usage_msg='set placement.constraints'
),
) )
required_if = [ required_if = [
@ -2269,7 +2285,7 @@ def main():
argument_spec=argument_spec, argument_spec=argument_spec,
required_if=required_if, required_if=required_if,
supports_check_mode=True, supports_check_mode=True,
min_docker_version='2.0.0', min_docker_version='2.0.2',
min_docker_api_version='1.24', min_docker_api_version='1.24',
option_minimal_versions=option_minimal_versions, option_minimal_versions=option_minimal_versions,
) )

View file

@ -69,7 +69,7 @@
force: yes force: yes
ignore_errors: yes ignore_errors: yes
# Maximum of 1.24 (docker API version for docker_swarm_service) and 1.25 (docker API version for docker_swarm) is 1.25 # Maximum of 1.24 (docker API version for docker_swarm_service) and 1.25 (docker API version for docker_swarm) is 1.25
when: docker_py_version is version('2.0.0', '>=') and docker_api_version is version('1.25', '>=') when: docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')
- fail: msg="Too old docker / docker-py version to run docker_swarm_service tests!" - fail: msg="Too old docker / docker-py version to run docker_swarm_service tests!"
when: not(docker_py_version is version('2.0.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) when: not(docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

View file

@ -1,108 +1,109 @@
--- ---
- block:
- name: Create a swarm service without name
register: output
docker_swarm_service:
state: present
ignore_errors: yes
- name: Create a swarm service without name - name: assert failure when name not set
register: output assert:
docker_swarm_service: that:
state: present - output is failed
ignore_errors: yes - 'output.msg == "missing required arguments: name"'
- name: assert failure when name not set - name: Remove an non-existing service
assert: register: output
that: docker_swarm_service:
- output is failed state: absent
- 'output.msg == "missing required arguments: name"' name: non_existing_service
- name: Remove an non-existing service - name: assert output not changed when deleting non-existing service
register: output assert:
docker_swarm_service: that:
state: absent - output is not changed
name: non_existing_service
- name: assert output not changed when deleting non-existing service - name: create sample service
assert: register: output
that: docker_swarm_service:
- output is not changed name: test_service
endpoint_mode: dnsrr
image: busybox
args:
- sleep
- "3600"
- name: create sample service - name: assert sample service is created
register: output assert:
docker_swarm_service: that:
name: test_service - output is changed
endpoint_mode: dnsrr
image: busybox
args:
- sleep
- "3600"
- name: assert sample service is created - name: change service args
assert: register: output
that: docker_swarm_service:
- output is changed name: test_service
image: busybox
args:
- sleep
- "1800"
- name: change service args - name: assert service args are correct
register: output assert:
docker_swarm_service: that:
name: test_service - output.swarm_service.args == ['sleep', '1800']
image: busybox
args:
- sleep
- "1800"
- name: assert service args are correct - name: set service mode to global
assert: register: output
that: docker_swarm_service:
- output.swarm_service.args == ['sleep', '1800'] name: test_service
image: busybox
endpoint_mode: vip
mode: global
args:
- sleep
- "1800"
- name: set service mode to global - name: assert service mode changed caused service rebuild
register: output assert:
docker_swarm_service: that:
name: test_service - output.rebuilt
image: busybox
endpoint_mode: vip
mode: global
args:
- sleep
- "1800"
- name: assert service mode changed caused service rebuild - name: add published ports to service
assert: register: output
that: docker_swarm_service:
- output.rebuilt name: test_service
image: busybox
mode: global
args:
- sleep
- "1800"
endpoint_mode: vip
publish:
- protocol: tcp
published_port: 60001
target_port: 60001
- protocol: udp
published_port: 60001
target_port: 60001
- name: add published ports to service - name: fake image key as it is not predictable
register: output set_fact:
docker_swarm_service: ansible_docker_service_output: "{{ output.swarm_service|combine({'image': 'busybox'}) }}"
name: test_service
image: busybox
mode: global
args:
- sleep
- "1800"
endpoint_mode: vip
publish:
- protocol: tcp
published_port: 60001
target_port: 60001
- protocol: udp
published_port: 60001
target_port: 60001
- name: fake image key as it is not predictable - name: assert service matches expectations
set_fact: assert:
ansible_docker_service_output: "{{ output.swarm_service|combine({'image': 'busybox'}) }}" that:
- ansible_docker_service_output == service_expected_output
- name: assert service matches expectations - name: delete sample service
assert: register: output
that: docker_swarm_service:
- ansible_docker_service_output == service_expected_output name: test_service
state: absent
- name: delete sample service - name: assert service deletion returns changed
register: output assert:
docker_swarm_service: that:
name: test_service - output is success
state: absent - output is changed
when: docker_api_version is version('1.24', '>=') and docker_py_version is version('3.0.0', '>=')
- name: assert service deletion returns changed
assert:
that:
- output is success
- output is changed

View file

@ -25,24 +25,28 @@
data: "hello" data: "hello"
state: present state: present
register: "config_result_1" register: "config_result_1"
when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
- docker_config: - docker_config:
name: "{{ config_name_2 }}" name: "{{ config_name_2 }}"
data: "test" data: "test"
state: present state: present
register: "config_result_2" register: "config_result_2"
when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
- docker_secret: - docker_secret:
name: "{{ secret_name_1 }}" name: "{{ secret_name_1 }}"
data: "secret1" data: "secret1"
state: "present" state: "present"
register: "secret_result_1" register: "secret_result_1"
when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
- docker_secret: - docker_secret:
name: "{{ secret_name_2 }}" name: "{{ secret_name_2 }}"
data: "secret2" data: "secret2"
state: "present" state: "present"
register: "secret_result_2" register: "secret_result_2"
when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
- docker_network: - docker_network:
name: "{{ network_name }}" name: "{{ network_name }}"
@ -132,10 +136,11 @@
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
configs: configs:
- config_id: "{{ config_result_1.config_id }}" - config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}" config_name: "{{ config_name_1 }}"
filename: "/tmp/{{ config_name_1 }}.txt" filename: "/tmp/{{ config_name_1 }}.txt"
register: configs_1 register: configs_1
ignore_errors: yes
- name: configs (idempotency) - name: configs (idempotency)
docker_swarm_service: docker_swarm_service:
@ -143,10 +148,11 @@
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
configs: configs:
- config_id: "{{ config_result_1.config_id }}" - config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}" config_name: "{{ config_name_1 }}"
filename: "/tmp/{{ config_name_1 }}.txt" filename: "/tmp/{{ config_name_1 }}.txt"
register: configs_2 register: configs_2
ignore_errors: yes
- name: configs (add) - name: configs (add)
docker_swarm_service: docker_swarm_service:
@ -154,13 +160,14 @@
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
configs: configs:
- config_id: "{{ config_result_1.config_id }}" - config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}" config_name: "{{ config_name_1 }}"
filename: "/tmp/{{ config_name_1 }}.txt" filename: "/tmp/{{ config_name_1 }}.txt"
- config_id: "{{ config_result_2.config_id }}" - config_id: "{{ config_result_2.config_id|default('') }}"
config_name: "{{ config_name_2 }}" config_name: "{{ config_name_2 }}"
filename: "/tmp/{{ config_name_2 }}.txt" filename: "/tmp/{{ config_name_2 }}.txt"
register: configs_3 register: configs_3
ignore_errors: yes
- name: configs (empty) - name: configs (empty)
docker_swarm_service: docker_swarm_service:
@ -169,6 +176,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
configs: [] configs: []
register: configs_4 register: configs_4
ignore_errors: yes
- name: configs (empty idempotency) - name: configs (empty idempotency)
docker_swarm_service: docker_swarm_service:
@ -177,6 +185,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
configs: [] configs: []
register: configs_5 register: configs_5
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -191,12 +200,13 @@
- configs_3 is changed - configs_3 is changed
- configs_4 is changed - configs_4 is changed
- configs_5 is not changed - configs_5 is not changed
when: docker_api_version is version('1.30', '>=') when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
- assert: - assert:
that: that:
- configs_1 is failed - configs_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.30') in configs_1.msg" - "'Minimum version required' in configs_1.msg"
when: docker_api_version is version('1.30', '<') when: docker_api_version is version('1.30', '<') or docker_py_version is version('2.6.0', '<')
#################################################################### ####################################################################
## command ######################################################### ## command #########################################################
@ -359,6 +369,7 @@
- 1.1.1.1 - 1.1.1.1
- 8.8.8.8 - 8.8.8.8
register: dns_1 register: dns_1
ignore_errors: yes
- name: dns (idempotency) - name: dns (idempotency)
docker_swarm_service: docker_swarm_service:
@ -369,6 +380,7 @@
- 1.1.1.1 - 1.1.1.1
- 8.8.8.8 - 8.8.8.8
register: dns_2 register: dns_2
ignore_errors: yes
- name: dns_servers (changed order) - name: dns_servers (changed order)
docker_swarm_service: docker_swarm_service:
@ -379,6 +391,7 @@
- 8.8.8.8 - 8.8.8.8
- 1.1.1.1 - 1.1.1.1
register: dns_3 register: dns_3
ignore_errors: yes
- name: dns_servers (changed elements) - name: dns_servers (changed elements)
docker_swarm_service: docker_swarm_service:
@ -389,6 +402,7 @@
- 8.8.8.8 - 8.8.8.8
- 9.9.9.9 - 9.9.9.9
register: dns_4 register: dns_4
ignore_errors: yes
- name: dns_servers (empty) - name: dns_servers (empty)
docker_swarm_service: docker_swarm_service:
@ -397,6 +411,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
dns: [] dns: []
register: dns_5 register: dns_5
ignore_errors: yes
- name: dns_servers (empty idempotency) - name: dns_servers (empty idempotency)
docker_swarm_service: docker_swarm_service:
@ -405,6 +420,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
dns: [] dns: []
register: dns_6 register: dns_6
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -420,12 +436,12 @@
- dns_4 is changed - dns_4 is changed
- dns_5 is changed - dns_5 is changed
- dns_6 is not changed - dns_6 is not changed
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
- assert: - assert:
that: that:
- dns_1 is failed - dns_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in dns_1.msg" - "'Minimum version required' in dns_1.msg"
when: docker_api_version is version('1.25', '<') when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
#################################################################### ####################################################################
## dns_options ##################################################### ## dns_options #####################################################
@ -495,12 +511,12 @@
- dns_options_3 is changed - dns_options_3 is changed
- dns_options_4 is changed - dns_options_4 is changed
- dns_options_5 is not changed - dns_options_5 is not changed
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
- assert: - assert:
that: that:
- dns_options_1 is failed - dns_options_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in dns_options_1.msg" - "'Minimum version required' in dns_options_1.msg"
when: docker_api_version is version('1.25', '<') when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
#################################################################### ####################################################################
## dns_search ###################################################### ## dns_search ######################################################
@ -515,6 +531,7 @@
- example.com - example.com
- example.org - example.org
register: dns_search_1 register: dns_search_1
ignore_errors: yes
- name: dns_search (idempotency) - name: dns_search (idempotency)
docker_swarm_service: docker_swarm_service:
@ -525,6 +542,7 @@
- example.com - example.com
- example.org - example.org
register: dns_search_2 register: dns_search_2
ignore_errors: yes
- name: dns_search (different order) - name: dns_search (different order)
docker_swarm_service: docker_swarm_service:
@ -535,6 +553,7 @@
- example.org - example.org
- example.com - example.com
register: dns_search_3 register: dns_search_3
ignore_errors: yes
- name: dns_search (changed elements) - name: dns_search (changed elements)
docker_swarm_service: docker_swarm_service:
@ -545,6 +564,7 @@
- ansible.com - ansible.com
- example.com - example.com
register: dns_search_4 register: dns_search_4
ignore_errors: yes
- name: dns_search (empty) - name: dns_search (empty)
docker_swarm_service: docker_swarm_service:
@ -553,6 +573,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
dns_search: [] dns_search: []
register: dns_search_5 register: dns_search_5
ignore_errors: yes
- name: dns_search (empty idempotency) - name: dns_search (empty idempotency)
docker_swarm_service: docker_swarm_service:
@ -561,6 +582,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
dns_search: [] dns_search: []
register: dns_search_6 register: dns_search_6
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -576,12 +598,12 @@
- dns_search_4 is changed - dns_search_4 is changed
- dns_search_5 is changed - dns_search_5 is changed
- dns_search_6 is not changed - dns_search_6 is not changed
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
- assert: - assert:
that: that:
- dns_search_1 is failed - dns_search_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in dns_search_1.msg" - "'Minimum version required' in dns_search_1.msg"
when: docker_api_version is version('1.25', '<') when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
#################################################################### ####################################################################
## endpoint_mode ################################################### ## endpoint_mode ###################################################
@ -594,6 +616,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
endpoint_mode: "dnsrr" endpoint_mode: "dnsrr"
register: endpoint_mode_1 register: endpoint_mode_1
ignore_errors: yes
- name: endpoint_mode (idempotency) - name: endpoint_mode (idempotency)
docker_swarm_service: docker_swarm_service:
@ -602,6 +625,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
endpoint_mode: "dnsrr" endpoint_mode: "dnsrr"
register: endpoint_mode_2 register: endpoint_mode_2
ignore_errors: yes
- name: endpoint_mode (changes) - name: endpoint_mode (changes)
docker_swarm_service: docker_swarm_service:
@ -610,6 +634,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
endpoint_mode: "vip" endpoint_mode: "vip"
register: endpoint_mode_3 register: endpoint_mode_3
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -622,6 +647,12 @@
- endpoint_mode_1 is changed - endpoint_mode_1 is changed
- endpoint_mode_2 is not changed - endpoint_mode_2 is not changed
- endpoint_mode_3 is changed - endpoint_mode_3 is changed
when: docker_api_version is version('1.25', '>=') and docker_py_version is version('3.0.0', '>=')
- assert:
that:
- endpoint_mode_1 is failed
- "'Minimum version required' in endpoint_mode_1.msg"
when: docker_api_version is version('1.25', '<') or docker_py_version is version('3.0.0', '<')
#################################################################### ####################################################################
## env ############################################################# ## env #############################################################
@ -799,6 +830,7 @@
- "3600" - "3600"
force_update: yes force_update: yes
register: force_update_1 register: force_update_1
ignore_errors: yes
- name: force_update (idempotency) - name: force_update (idempotency)
docker_swarm_service: docker_swarm_service:
@ -810,6 +842,7 @@
- "3600" - "3600"
force_update: yes force_update: yes
register: force_update_2 register: force_update_2
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -821,12 +854,12 @@
that: that:
- force_update_1 is changed - force_update_1 is changed
- force_update_2 is changed - force_update_2 is changed
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
- assert: - assert:
that: that:
- force_update_1 is failed - force_update_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in force_update_1.msg" - "'Minimum version required' in force_update_1.msg"
when: docker_api_version is version('1.25', '<') when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.1.0', '<')
#################################################################### ####################################################################
## groups ########################################################## ## groups ##########################################################
@ -841,6 +874,7 @@
- 1234 - 1234
- 5678 - 5678
register: groups_1 register: groups_1
ignore_errors: yes
- name: groups (idempotency) - name: groups (idempotency)
docker_swarm_service: docker_swarm_service:
@ -851,6 +885,7 @@
- 1234 - 1234
- 5678 - 5678
register: groups_2 register: groups_2
ignore_errors: yes
- name: groups (change) - name: groups (change)
docker_swarm_service: docker_swarm_service:
@ -860,6 +895,7 @@
groups: groups:
- 1234 - 1234
register: groups_3 register: groups_3
ignore_errors: yes
- name: groups (empty) - name: groups (empty)
docker_swarm_service: docker_swarm_service:
@ -868,6 +904,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
groups: [] groups: []
register: groups_4 register: groups_4
ignore_errors: yes
- name: groups (empty idempotency) - name: groups (empty idempotency)
docker_swarm_service: docker_swarm_service:
@ -876,6 +913,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
groups: [] groups: []
register: groups_5 register: groups_5
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -890,6 +928,12 @@
- groups_3 is changed - groups_3 is changed
- groups_4 is changed - groups_4 is changed
- groups_5 is not changed - groups_5 is not changed
when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
- assert:
that:
- groups_1 is failed
- "'Minimum version required' in groups_1.msg"
when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
#################################################################### ####################################################################
## healthcheck ##################################################### ## healthcheck #####################################################
@ -909,6 +953,7 @@
interval: 0h0m2s3ms4us interval: 0h0m2s3ms4us
retries: 2 retries: 2
register: healthcheck_1 register: healthcheck_1
ignore_errors: yes
- name: healthcheck (idempotency) - name: healthcheck (idempotency)
docker_swarm_service: docker_swarm_service:
@ -924,6 +969,7 @@
interval: 0h0m2s3ms4us interval: 0h0m2s3ms4us
retries: 2 retries: 2
register: healthcheck_2 register: healthcheck_2
ignore_errors: yes
- name: healthcheck (changed) - name: healthcheck (changed)
docker_swarm_service: docker_swarm_service:
@ -939,6 +985,7 @@
interval: 0h1m2s3ms4us interval: 0h1m2s3ms4us
retries: 3 retries: 3
register: healthcheck_3 register: healthcheck_3
ignore_errors: yes
- name: healthcheck (disabled) - name: healthcheck (disabled)
docker_swarm_service: docker_swarm_service:
@ -949,6 +996,7 @@
test: test:
- NONE - NONE
register: healthcheck_4 register: healthcheck_4
ignore_errors: yes
- name: healthcheck (disabled, idempotency) - name: healthcheck (disabled, idempotency)
docker_swarm_service: docker_swarm_service:
@ -959,6 +1007,7 @@
test: test:
- NONE - NONE
register: healthcheck_5 register: healthcheck_5
ignore_errors: yes
- name: healthcheck (string in healthcheck test, changed) - name: healthcheck (string in healthcheck test, changed)
docker_swarm_service: docker_swarm_service:
@ -968,6 +1017,7 @@
healthcheck: healthcheck:
test: "sleep 1" test: "sleep 1"
register: healthcheck_6 register: healthcheck_6
ignore_errors: yes
- name: healthcheck (string in healthcheck test, idempotency) - name: healthcheck (string in healthcheck test, idempotency)
docker_swarm_service: docker_swarm_service:
@ -977,6 +1027,7 @@
healthcheck: healthcheck:
test: "sleep 1" test: "sleep 1"
register: healthcheck_7 register: healthcheck_7
ignore_errors: yes
- name: healthcheck (empty) - name: healthcheck (empty)
docker_swarm_service: docker_swarm_service:
@ -985,6 +1036,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
labels: {} labels: {}
register: healthcheck_8 register: healthcheck_8
ignore_errors: yes
- name: healthcheck (empty idempotency) - name: healthcheck (empty idempotency)
docker_swarm_service: docker_swarm_service:
@ -993,6 +1045,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
labels: {} labels: {}
register: healthcheck_9 register: healthcheck_9
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -1011,12 +1064,12 @@
- healthcheck_7 is not changed - healthcheck_7 is not changed
- healthcheck_8 is changed - healthcheck_8 is changed
- healthcheck_9 is not changed - healthcheck_9 is not changed
when: docker_py_version is version('2.4.0', '>=') when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
- assert: - assert:
that: that:
- healthcheck_1 is failed - healthcheck_1 is failed
- "('version is ' ~ docker_py_version ~'. Minimum version required is 2.4.0') in healthcheck_1.msg" - "'Minimum version required' in healthcheck_1.msg"
when: docker_py_version is version('2.4.0', '<') when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
################################################################### ###################################################################
## hostname ####################################################### ## hostname #######################################################
@ -1029,6 +1082,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
hostname: me.example.com hostname: me.example.com
register: hostname_1 register: hostname_1
ignore_errors: yes
- name: hostname (idempotency) - name: hostname (idempotency)
docker_swarm_service: docker_swarm_service:
@ -1037,6 +1091,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
hostname: me.example.com hostname: me.example.com
register: hostname_2 register: hostname_2
ignore_errors: yes
- name: hostname (change) - name: hostname (change)
docker_swarm_service: docker_swarm_service:
@ -1045,6 +1100,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
hostname: me.example.org hostname: me.example.org
register: hostname_3 register: hostname_3
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -1057,12 +1113,12 @@
- hostname_1 is changed - hostname_1 is changed
- hostname_2 is not changed - hostname_2 is not changed
- hostname_3 is changed - hostname_3 is changed
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.2.0', '>=')
- assert: - assert:
that: that:
- hostname_1 is failed - hostname_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in hostname_1.msg" - "'Minimum version required' in hostname_1.msg"
when: docker_api_version is version('1.25', '<') when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.2.0', '<')
################################################################### ###################################################################
## hosts ########################################################## ## hosts ##########################################################
@ -1077,6 +1133,7 @@
example.com: 1.2.3.4 example.com: 1.2.3.4
example.org: 4.3.2.1 example.org: 4.3.2.1
register: hosts_1 register: hosts_1
ignore_errors: yes
- name: hosts (idempotency) - name: hosts (idempotency)
docker_swarm_service: docker_swarm_service:
@ -1087,6 +1144,7 @@
example.com: 1.2.3.4 example.com: 1.2.3.4
example.org: 4.3.2.1 example.org: 4.3.2.1
register: hosts_2 register: hosts_2
ignore_errors: yes
- name: hosts (change) - name: hosts (change)
docker_swarm_service: docker_swarm_service:
@ -1096,6 +1154,7 @@
hosts: hosts:
example.com: 1.2.3.4 example.com: 1.2.3.4
register: hosts_3 register: hosts_3
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -1108,12 +1167,12 @@
- hosts_1 is changed - hosts_1 is changed
- hosts_2 is not changed - hosts_2 is not changed
- hosts_3 is changed - hosts_3 is changed
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
- assert: - assert:
that: that:
- hosts_1 is failed - hosts_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in hosts_1.msg" - "'Minimum version required' in hosts_1.msg"
when: docker_api_version is version('1.25', '<') when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
################################################################### ###################################################################
@ -1427,41 +1486,41 @@
that: that:
- networks_3.rebuilt == false - networks_3.rebuilt == false
- networks_5.rebuilt == false - networks_5.rebuilt == false
when: docker_api_version is version('1.29', '>=') when: docker_api_version is version('1.29', '>=') and docker_py_version is version('2.7.0', '>=')
- assert: - assert:
that: that:
- networks_3.rebuilt == true - networks_3.rebuilt == true
- networks_5.rebuilt == true - networks_5.rebuilt == true
when: docker_api_version is version('1.29', '<') when: docker_api_version is version('1.29', '<') or docker_py_version is version('2.7.0', '<')
#################################################################### ####################################################################
## stop_grace_period ############################################### ## stop_grace_period ###############################################
#################################################################### ####################################################################
- name: stop_signal - name: stop_grace_period
docker_swarm_service: docker_swarm_service:
name: "{{ service_name }}" name: "{{ service_name }}"
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
stop_grace_period: 60s stop_grace_period: 60s
register: stop_signal_1 register: stop_grace_period_1
- name: stop_signal (idempotency) - name: stop_grace_period (idempotency)
docker_swarm_service: docker_swarm_service:
name: "{{ service_name }}" name: "{{ service_name }}"
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
stop_grace_period: 60s stop_grace_period: 60s
register: stop_signal_2 register: stop_grace_period_2
- name: stop_signal (change) - name: stop_grace_period (change)
docker_swarm_service: docker_swarm_service:
name: "{{ service_name }}" name: "{{ service_name }}"
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
stop_grace_period: 1m30s stop_grace_period: 1m30s
register: stop_signal_3 register: stop_grace_period_3
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -1471,9 +1530,9 @@
- assert: - assert:
that: that:
- stop_signal_1 is changed - stop_grace_period_1 is changed
- stop_signal_2 is not changed - stop_grace_period_2 is not changed
- stop_signal_3 is changed - stop_grace_period_3 is changed
#################################################################### ####################################################################
## stop_signal ##################################################### ## stop_signal #####################################################
@ -1484,24 +1543,27 @@
name: "{{ service_name }}" name: "{{ service_name }}"
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
stop_signal: 30 stop_signal: "30"
register: stop_signal_1 register: stop_signal_1
ignore_errors: yes
- name: stop_signal (idempotency) - name: stop_signal (idempotency)
docker_swarm_service: docker_swarm_service:
name: "{{ service_name }}" name: "{{ service_name }}"
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
stop_signal: 30 stop_signal: "30"
register: stop_signal_2 register: stop_signal_2
ignore_errors: yes
- name: stop_signal (change) - name: stop_signal (change)
docker_swarm_service: docker_swarm_service:
name: "{{ service_name }}" name: "{{ service_name }}"
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
stop_signal: 9 stop_signal: "9"
register: stop_signal_3 register: stop_signal_3
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -1514,6 +1576,12 @@
- stop_signal_1 is changed - stop_signal_1 is changed
- stop_signal_2 is not changed - stop_signal_2 is not changed
- stop_signal_3 is changed - stop_signal_3 is changed
when: docker_api_version is version('1.28', '>=') and docker_py_version is version('2.6.0', '>=')
- assert:
that:
- stop_signal_1 is failed
- "'Minimum version required' in stop_signal_1.msg"
when: docker_api_version is version('1.28', '<') or docker_py_version is version('2.6.0', '<')
#################################################################### ####################################################################
## publish ######################################################### ## publish #########################################################
@ -1532,6 +1600,7 @@
published_port: 60002 published_port: 60002
target_port: 60002 target_port: 60002
register: publish_1 register: publish_1
ignore_errors: yes
- name: publish (idempotency) - name: publish (idempotency)
docker_swarm_service: docker_swarm_service:
@ -1545,6 +1614,7 @@
- published_port: 60001 - published_port: 60001
target_port: 60001 target_port: 60001
register: publish_2 register: publish_2
ignore_errors: yes
- name: publish (change) - name: publish (change)
docker_swarm_service: docker_swarm_service:
@ -1559,6 +1629,7 @@
published_port: 60001 published_port: 60001
target_port: 60001 target_port: 60001
register: publish_3 register: publish_3
ignore_errors: yes
- name: publish (mode) - name: publish (mode)
docker_swarm_service: docker_swarm_service:
@ -1575,6 +1646,7 @@
target_port: 60001 target_port: 60001
mode: host mode: host
register: publish_4 register: publish_4
ignore_errors: yes
- name: publish (mode idempotency) - name: publish (mode idempotency)
docker_swarm_service: docker_swarm_service:
@ -1591,6 +1663,7 @@
target_port: 60003 target_port: 60003
mode: host mode: host
register: publish_5 register: publish_5
ignore_errors: yes
- name: publish (empty) - name: publish (empty)
docker_swarm_service: docker_swarm_service:
@ -1599,6 +1672,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
publish: [] publish: []
register: publish_6 register: publish_6
ignore_errors: yes
- name: publish (empty idempotency) - name: publish (empty idempotency)
docker_swarm_service: docker_swarm_service:
@ -1607,6 +1681,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
publish: [] publish: []
register: publish_7 register: publish_7
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -1623,12 +1698,12 @@
- publish_5 is not changed - publish_5 is not changed
- publish_6 is changed - publish_6 is changed
- publish_7 is not changed - publish_7 is not changed
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=') and docker_py_version is version('3.0.0', '>=')
- assert: - assert:
that: that:
- publish_1 is failed - publish_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in publish_1.msg" - "'Minimum version required' in publish_1.msg"
when: docker_api_version is version('1.25', '<') when: docker_api_version is version('1.25', '<') or docker_py_version is version('3.0.0', '<')
################################################################### ###################################################################
## replicas ####################################################### ## replicas #######################################################
@ -1709,6 +1784,13 @@
- resolve_image_1 is changed - resolve_image_1 is changed
- resolve_image_2 is not changed - resolve_image_2 is not changed
- resolve_image_3 is changed - resolve_image_3 is changed
when: docker_api_version is version('1.30', '>=') and docker_py_version is version('3.2.0', '>=')
- assert:
that:
- resolve_image_1 is changed
- resolve_image_2 is not changed
- resolve_image_3 is not changed
when: docker_api_version is version('1.30', '<') or docker_py_version is version('3.2.0', '<')
#################################################################### ####################################################################
## secrets ######################################################### ## secrets #########################################################
@ -1720,10 +1802,11 @@
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
secrets: secrets:
- secret_id: "{{ secret_result_1.secret_id }}" - secret_id: "{{ secret_result_1.secret_id|default('') }}"
secret_name: "{{ secret_name_1 }}" secret_name: "{{ secret_name_1 }}"
filename: "/run/secrets/{{ secret_name_1 }}.txt" filename: "/run/secrets/{{ secret_name_1 }}.txt"
register: secrets_1 register: secrets_1
ignore_errors: yes
- name: secrets (idempotency) - name: secrets (idempotency)
docker_swarm_service: docker_swarm_service:
@ -1731,10 +1814,11 @@
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
secrets: secrets:
- secret_id: "{{ secret_result_1.secret_id }}" - secret_id: "{{ secret_result_1.secret_id|default('') }}"
secret_name: "{{ secret_name_1 }}" secret_name: "{{ secret_name_1 }}"
filename: "/run/secrets/{{ secret_name_1 }}.txt" filename: "/run/secrets/{{ secret_name_1 }}.txt"
register: secrets_2 register: secrets_2
ignore_errors: yes
- name: secrets (add) - name: secrets (add)
docker_swarm_service: docker_swarm_service:
@ -1742,13 +1826,14 @@
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
secrets: secrets:
- secret_id: "{{ secret_result_1.secret_id }}" - secret_id: "{{ secret_result_1.secret_id|default('') }}"
secret_name: "{{ secret_name_1 }}" secret_name: "{{ secret_name_1 }}"
filename: "/run/secrets/{{ secret_name_1 }}.txt" filename: "/run/secrets/{{ secret_name_1 }}.txt"
- secret_id: "{{ secret_result_2.secret_id }}" - secret_id: "{{ secret_result_2.secret_id|default('') }}"
secret_name: "{{ secret_name_2 }}" secret_name: "{{ secret_name_2 }}"
filename: "/run/secrets/{{ secret_name_2 }}.txt" filename: "/run/secrets/{{ secret_name_2 }}.txt"
register: secrets_3 register: secrets_3
ignore_errors: yes
- name: secrets (empty) - name: secrets (empty)
docker_swarm_service: docker_swarm_service:
@ -1757,6 +1842,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
secrets: [] secrets: []
register: secrets_4 register: secrets_4
ignore_errors: yes
- name: secrets (empty idempotency) - name: secrets (empty idempotency)
docker_swarm_service: docker_swarm_service:
@ -1765,6 +1851,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
secrets: [] secrets: []
register: secrets_5 register: secrets_5
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -1779,12 +1866,13 @@
- secrets_3 is changed - secrets_3 is changed
- secrets_4 is changed - secrets_4 is changed
- secrets_5 is not changed - secrets_5 is not changed
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.4.0', '>=')
- assert: - assert:
that: that:
- secrets_1 is failed - secrets_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in secrets_1.msg" - "'Minimum version required' in secrets_1.msg"
when: docker_api_version is version('1.25', '<') when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.4.0', '<')
################################################################### ###################################################################
# tty ############################################################# # tty #############################################################
@ -1797,6 +1885,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
tty: yes tty: yes
register: tty_1 register: tty_1
ignore_errors: yes
- name: tty (idempotency) - name: tty (idempotency)
docker_swarm_service: docker_swarm_service:
@ -1805,6 +1894,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
tty: yes tty: yes
register: tty_2 register: tty_2
ignore_errors: yes
- name: tty (change) - name: tty (change)
docker_swarm_service: docker_swarm_service:
@ -1813,6 +1903,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
tty: no tty: no
register: tty_3 register: tty_3
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -1825,12 +1916,12 @@
- tty_1 is changed - tty_1 is changed
- tty_2 is not changed - tty_2 is not changed
- tty_3 is changed - tty_3 is changed
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.4.0', '>=')
- assert: - assert:
that: that:
- tty_1 is failed - tty_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in tty_1.msg" - "'Minimum version required' in tty_1.msg"
when: docker_api_version is version('1.25', '<') when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.4.0', '<')
################################################################### ###################################################################
## user ########################################################### ## user ###########################################################
@ -1937,7 +2028,7 @@
ignore_errors: yes ignore_errors: yes
- name: Delete configs - name: Delete configs
docker_network: docker_config:
name: "{{ config_name }}" name: "{{ config_name }}"
state: absent state: absent
force: yes force: yes
@ -1947,9 +2038,10 @@
loop_control: loop_control:
loop_var: config_name loop_var: config_name
ignore_errors: yes ignore_errors: yes
when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
- name: Delete secrets - name: Delete secrets
docker_network: docker_secret:
name: "{{ secret_name }}" name: "{{ secret_name }}"
state: absent state: absent
force: yes force: yes
@ -1959,3 +2051,4 @@
loop_control: loop_control:
loop_var: secret_name loop_var: secret_name
ignore_errors: yes ignore_errors: yes
when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')

View file

@ -22,6 +22,7 @@
preferences: preferences:
- spread: "node.labels.test" - spread: "node.labels.test"
register: placement_preferences_1 register: placement_preferences_1
ignore_errors: yes
- name: placement.preferences (idempotency) - name: placement.preferences (idempotency)
docker_swarm_service: docker_swarm_service:
@ -32,6 +33,7 @@
preferences: preferences:
- spread: "node.labels.test" - spread: "node.labels.test"
register: placement_preferences_2 register: placement_preferences_2
ignore_errors: yes
- name: placement.preferences (change) - name: placement.preferences (change)
docker_swarm_service: docker_swarm_service:
@ -42,6 +44,7 @@
preferences: preferences:
- spread: "node.labels.test2" - spread: "node.labels.test2"
register: placement_preferences_3 register: placement_preferences_3
ignore_errors: yes
- name: placement.preferences (empty) - name: placement.preferences (empty)
docker_swarm_service: docker_swarm_service:
@ -51,6 +54,7 @@
placement: placement:
preferences: [] preferences: []
register: placement_preferences_4 register: placement_preferences_4
ignore_errors: yes
- name: placement.preferences (empty idempotency) - name: placement.preferences (empty idempotency)
docker_swarm_service: docker_swarm_service:
@ -60,6 +64,7 @@
placement: placement:
preferences: [] preferences: []
register: placement_preferences_5 register: placement_preferences_5
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -74,6 +79,12 @@
- placement_preferences_3 is changed - placement_preferences_3 is changed
- placement_preferences_4 is changed - placement_preferences_4 is changed
- placement_preferences_5 is not changed - placement_preferences_5 is not changed
when: docker_api_version is version('1.27', '>=') and docker_py_version is version('2.4.0', '>=')
- assert:
that:
- placement_preferences_1 is failed
- "'Minimum version required' in placement_preferences_1.msg"
when: docker_api_version is version('1.27', '<') or docker_py_version is version('2.4.0', '<')
#################################################################### ####################################################################
## placement.constraints ##################################################### ## placement.constraints #####################################################
@ -88,6 +99,7 @@
constraints: constraints:
- "node.role == manager" - "node.role == manager"
register: constraints_1 register: constraints_1
ignore_errors: yes
- name: placement.constraints (idempotency) - name: placement.constraints (idempotency)
docker_swarm_service: docker_swarm_service:
@ -98,6 +110,7 @@
constraints: constraints:
- "node.role == manager" - "node.role == manager"
register: constraints_2 register: constraints_2
ignore_errors: yes
- name: constraints (idempotency, old name) - name: constraints (idempotency, old name)
docker_swarm_service: docker_swarm_service:
@ -107,6 +120,7 @@
constraints: constraints:
- "node.role == manager" - "node.role == manager"
register: constraints_2b register: constraints_2b
ignore_errors: yes
- name: placement.constraints (change) - name: placement.constraints (change)
docker_swarm_service: docker_swarm_service:
@ -117,6 +131,7 @@
constraints: constraints:
- "node.role == worker" - "node.role == worker"
register: constraints_3 register: constraints_3
ignore_errors: yes
- name: placement.constraints (empty) - name: placement.constraints (empty)
docker_swarm_service: docker_swarm_service:
@ -126,6 +141,7 @@
placement: placement:
constraints: [] constraints: []
register: constraints_4 register: constraints_4
ignore_errors: yes
- name: placement.constraints (empty idempotency) - name: placement.constraints (empty idempotency)
docker_swarm_service: docker_swarm_service:
@ -135,6 +151,7 @@
placement: placement:
constraints: [] constraints: []
register: constraints_5 register: constraints_5
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -150,3 +167,9 @@
- constraints_3 is changed - constraints_3 is changed
- constraints_4 is changed - constraints_4 is changed
- constraints_5 is not changed - constraints_5 is not changed
when: docker_api_version is version('1.27', '>=') and docker_py_version is version('2.4.0', '>=')
- assert:
that:
- constraints_1 is failed
- "'Minimum version required' in constraints_1.msg"
when: docker_api_version is version('1.27', '<') or docker_py_version is version('2.4.0', '<')

View file

@ -87,7 +87,7 @@
name: "{{ service_name }}" name: "{{ service_name }}"
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
limit_memory: 67108864 limit_memory: "67108864"
register: limit_memory_2b register: limit_memory_2b
- name: limits.memory (change) - name: limits.memory (change)
@ -189,7 +189,7 @@
name: "{{ service_name }}" name: "{{ service_name }}"
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
reserve_memory: 67108864 reserve_memory: "67108864"
register: reserve_memory_2b register: reserve_memory_2b
- name: reservations.memory (change) - name: reservations.memory (change)

View file

@ -124,6 +124,7 @@
update_config: update_config:
max_failure_ratio: 0.25 max_failure_ratio: 0.25
register: update_max_failure_ratio_1 register: update_max_failure_ratio_1
ignore_errors: yes
- name: update_config.max_failure_ratio (idempotency) - name: update_config.max_failure_ratio (idempotency)
docker_swarm_service: docker_swarm_service:
@ -133,6 +134,7 @@
update_config: update_config:
max_failure_ratio: 0.25 max_failure_ratio: 0.25
register: update_max_failure_ratio_2 register: update_max_failure_ratio_2
ignore_errors: yes
- name: update_max_failure_ratio (idempotency, old name) - name: update_max_failure_ratio (idempotency, old name)
docker_swarm_service: docker_swarm_service:
@ -141,6 +143,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
update_max_failure_ratio: 0.25 update_max_failure_ratio: 0.25
register: update_max_failure_ratio_2b register: update_max_failure_ratio_2b
ignore_errors: yes
- name: update_config.max_failure_ratio (change) - name: update_config.max_failure_ratio (change)
docker_swarm_service: docker_swarm_service:
@ -150,6 +153,7 @@
update_config: update_config:
max_failure_ratio: 0.50 max_failure_ratio: 0.50
register: update_max_failure_ratio_3 register: update_max_failure_ratio_3
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -163,6 +167,12 @@
- update_max_failure_ratio_2 is not changed - update_max_failure_ratio_2 is not changed
- update_max_failure_ratio_2b is not changed - update_max_failure_ratio_2b is not changed
- update_max_failure_ratio_3 is changed - update_max_failure_ratio_3 is changed
when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
- assert:
that:
- update_max_failure_ratio_1 is failed
- "'Minimum version required' in update_max_failure_ratio_1.msg"
when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.1.0', '<')
################################################################### ###################################################################
# update_config.monitor ########################################### # update_config.monitor ###########################################
@ -176,6 +186,7 @@
update_config: update_config:
monitor: 10s monitor: 10s
register: update_monitor_1 register: update_monitor_1
ignore_errors: yes
- name: update_config.monitor (idempotency) - name: update_config.monitor (idempotency)
docker_swarm_service: docker_swarm_service:
@ -185,6 +196,7 @@
update_config: update_config:
monitor: 10s monitor: 10s
register: update_monitor_2 register: update_monitor_2
ignore_errors: yes
- name: update_monitor (idempotency, old name) - name: update_monitor (idempotency, old name)
docker_swarm_service: docker_swarm_service:
@ -193,6 +205,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
update_monitor: 10s update_monitor: 10s
register: update_monitor_2b register: update_monitor_2b
ignore_errors: yes
- name: update_config.monitor (change) - name: update_config.monitor (change)
docker_swarm_service: docker_swarm_service:
@ -202,6 +215,7 @@
update_config: update_config:
monitor: 60s monitor: 60s
register: update_monitor_3 register: update_monitor_3
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -215,6 +229,12 @@
- update_monitor_2 is not changed - update_monitor_2 is not changed
- update_monitor_2b is not changed - update_monitor_2b is not changed
- update_monitor_3 is changed - update_monitor_3 is changed
when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
- assert:
that:
- update_monitor_1 is failed
- "'Minimum version required' in update_monitor_1.msg"
when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.1.0', '<')
################################################################### ###################################################################
# update_config.order ############################################# # update_config.order #############################################
@ -228,6 +248,7 @@
update_config: update_config:
order: "start-first" order: "start-first"
register: update_order_1 register: update_order_1
ignore_errors: yes
- name: update_config.order (idempotency) - name: update_config.order (idempotency)
docker_swarm_service: docker_swarm_service:
@ -237,6 +258,7 @@
update_config: update_config:
order: "start-first" order: "start-first"
register: update_order_2 register: update_order_2
ignore_errors: yes
- name: update_order (idempotency, old name) - name: update_order (idempotency, old name)
docker_swarm_service: docker_swarm_service:
@ -245,6 +267,7 @@
command: '/bin/sh -v -c "sleep 10m"' command: '/bin/sh -v -c "sleep 10m"'
update_order: "start-first" update_order: "start-first"
register: update_order_2b register: update_order_2b
ignore_errors: yes
- name: update_config.order (change) - name: update_config.order (change)
docker_swarm_service: docker_swarm_service:
@ -254,6 +277,7 @@
update_config: update_config:
order: "stop-first" order: "stop-first"
register: update_order_3 register: update_order_3
ignore_errors: yes
- name: cleanup - name: cleanup
docker_swarm_service: docker_swarm_service:
@ -267,12 +291,12 @@
- update_order_2 is not changed - update_order_2 is not changed
- update_order_2b is not changed - update_order_2b is not changed
- update_order_3 is changed - update_order_3 is changed
when: docker_api_version is version('1.29', '>=') when: docker_api_version is version('1.29', '>=') and docker_py_version is version('2.7.0', '>=')
- assert: - assert:
that: that:
- secrets_1 is failed - update_order_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.29') in update_order_1.msg" - "'Minimum version required' in update_order_1.msg"
when: docker_api_version is version('1.29', '<') when: docker_api_version is version('1.29', '<') or docker_py_version is version('2.7.0', '<')
################################################################### ###################################################################
## update_config.parallelism ###################################### ## update_config.parallelism ######################################