mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
docker_swarm_service: Fix crash when using configs parameter (#50606)
* Fix crash when using configs parameter * Don’t add difference for configs set to None * Add changelog fragment * Revert "Add changelog fragment" This reverts commit 8df497e3881d976e7417d2662a167694fbc33147. * Enable config tests * Pass empty list of configs to docker * Properly clean up after all tests
This commit is contained in:
parent
393bf5e4b1
commit
9c44dc371b
2 changed files with 84 additions and 56 deletions
|
@ -552,7 +552,7 @@ class DockerService(DockerBaseClass):
|
||||||
self.mode = "replicated"
|
self.mode = "replicated"
|
||||||
self.user = "root"
|
self.user = "root"
|
||||||
self.mounts = []
|
self.mounts = []
|
||||||
self.configs = None
|
self.configs = []
|
||||||
self.secrets = []
|
self.secrets = []
|
||||||
self.constraints = []
|
self.constraints = []
|
||||||
self.networks = []
|
self.networks = []
|
||||||
|
@ -688,7 +688,7 @@ class DockerService(DockerBaseClass):
|
||||||
s.mounts.append(service_m)
|
s.mounts.append(service_m)
|
||||||
|
|
||||||
s.configs = None
|
s.configs = None
|
||||||
if ap['configs']:
|
if ap['configs'] is not None:
|
||||||
s.configs = []
|
s.configs = []
|
||||||
for param_m in ap['configs']:
|
for param_m in ap['configs']:
|
||||||
service_c = {}
|
service_c = {}
|
||||||
|
@ -729,7 +729,7 @@ class DockerService(DockerBaseClass):
|
||||||
differences.add('mode', parameter=self.mode, active=os.mode)
|
differences.add('mode', parameter=self.mode, active=os.mode)
|
||||||
if self.mounts != os.mounts:
|
if self.mounts != os.mounts:
|
||||||
differences.add('mounts', parameter=self.mounts, active=os.mounts)
|
differences.add('mounts', parameter=self.mounts, active=os.mounts)
|
||||||
if self.configs != os.configs:
|
if self.configs is not None and self.configs != os.configs:
|
||||||
differences.add('configs', parameter=self.configs, active=os.configs)
|
differences.add('configs', parameter=self.configs, active=os.configs)
|
||||||
if self.secrets != os.secrets:
|
if self.secrets != os.secrets:
|
||||||
differences.add('secrets', parameter=self.secrets, active=os.secrets)
|
differences.add('secrets', parameter=self.secrets, active=os.secrets)
|
||||||
|
|
|
@ -110,60 +110,64 @@
|
||||||
## configs #########################################################
|
## configs #########################################################
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|
||||||
# FIXME: Broken until #50606 is merged
|
- name: configs
|
||||||
|
docker_swarm_service:
|
||||||
|
name: "{{ service_name }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
configs:
|
||||||
|
- config_id: "{{ config_result_1.config_id }}"
|
||||||
|
config_name: "{{ config_name_1 }}"
|
||||||
|
filename: "/tmp/{{ config_name_1 }}.txt"
|
||||||
|
register: configs_1
|
||||||
|
|
||||||
#- name: configs
|
- name: configs (idempotency)
|
||||||
# docker_swarm_service:
|
docker_swarm_service:
|
||||||
# name: "{{ service_name }}"
|
name: "{{ service_name }}"
|
||||||
# image: alpine:3.8
|
image: alpine:3.8
|
||||||
# configs:
|
configs:
|
||||||
# - config_id: "{{ config_result_1.config_id }}"
|
- config_id: "{{ config_result_1.config_id }}"
|
||||||
# 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_2
|
||||||
#
|
|
||||||
#- name: configs (idempotency)
|
- name: configs (add)
|
||||||
# docker_swarm_service:
|
docker_swarm_service:
|
||||||
# name: "{{ service_name }}"
|
name: "{{ service_name }}"
|
||||||
# image: alpine:3.8
|
image: alpine:3.8
|
||||||
# configs:
|
configs:
|
||||||
# - config_id: "{{ config_result_1.config_id }}"
|
- config_id: "{{ config_result_1.config_id }}"
|
||||||
# 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
|
- config_id: "{{ config_result_2.config_id }}"
|
||||||
#
|
config_name: "{{ config_name_2 }}"
|
||||||
#- name: configs (add)
|
filename: "/tmp/{{ config_name_2 }}.txt"
|
||||||
# docker_swarm_service:
|
register: configs_3
|
||||||
# name: "{{ service_name }}"
|
|
||||||
# image: alpine:3.8
|
- name: configs (empty)
|
||||||
# configs:
|
docker_swarm_service:
|
||||||
# - config_id: "{{ config_result_1.config_id }}"
|
name: "{{ service_name }}"
|
||||||
# config_name: "{{ config_name_1 }}"
|
image: alpine:3.8
|
||||||
# filename: "/tmp/{{ config_name_1 }}.txt"
|
configs: []
|
||||||
# - config_id: "{{ config_result_2.config_id }}"
|
register: configs_4
|
||||||
# config_name: "{{ config_name_2 }}"
|
|
||||||
# filename: "/tmp/{{ config_name_2 }}.txt"
|
- name: cleanup
|
||||||
# register: configs_3
|
docker_swarm_service:
|
||||||
#
|
name: "{{ service_name }}"
|
||||||
#- name: configs (empty)
|
state: absent
|
||||||
# docker_swarm_service:
|
diff: no
|
||||||
# name: "{{ service_name }}"
|
|
||||||
# image: alpine:3.8
|
- assert:
|
||||||
# configs: []
|
that:
|
||||||
# register: configs_4
|
- configs_1 is changed
|
||||||
#
|
- configs_2 is not changed
|
||||||
#- assert:
|
- configs_3 is changed
|
||||||
# that:
|
- configs_4 is changed
|
||||||
# - configs_1 is changed
|
when: docker_api_version is version('1.30', '>=')
|
||||||
# - configs_2 is not changed
|
- assert:
|
||||||
# - configs_3 is changed
|
that:
|
||||||
# - configs_4 is changed
|
- configs_1 is failed
|
||||||
# when: docker_api_version is version('1.30', '>=')
|
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.30') in configs_1.msg"
|
||||||
#- assert:
|
when: docker_api_version is version('1.30', '<')
|
||||||
# that:
|
|
||||||
# - configs_1 is failed
|
|
||||||
# - "('version is ' ~ docker_api_version ~'. Minimum version required is 1.30') in configs_1.msg"
|
|
||||||
# when: docker_api_version is version('1.30', '<')
|
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
## constraints #####################################################
|
## constraints #####################################################
|
||||||
|
@ -910,6 +914,12 @@
|
||||||
mounts: []
|
mounts: []
|
||||||
register: mounts_4
|
register: mounts_4
|
||||||
|
|
||||||
|
- name: cleanup
|
||||||
|
docker_swarm_service:
|
||||||
|
name: "{{ service_name }}"
|
||||||
|
state: absent
|
||||||
|
diff: no
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- mounts_1 is changed
|
- mounts_1 is changed
|
||||||
|
@ -944,6 +954,12 @@
|
||||||
networks: []
|
networks: []
|
||||||
register: networks_3
|
register: networks_3
|
||||||
|
|
||||||
|
- name: cleanup
|
||||||
|
docker_swarm_service:
|
||||||
|
name: "{{ service_name }}"
|
||||||
|
state: absent
|
||||||
|
diff: no
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- networks_1 is changed
|
- networks_1 is changed
|
||||||
|
@ -1062,6 +1078,12 @@
|
||||||
mode: host
|
mode: host
|
||||||
register: publish_5
|
register: publish_5
|
||||||
|
|
||||||
|
- name: cleanup
|
||||||
|
docker_swarm_service:
|
||||||
|
name: "{{ service_name }}"
|
||||||
|
state: absent
|
||||||
|
diff: no
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- publish_1 is changed
|
- publish_1 is changed
|
||||||
|
@ -1379,6 +1401,12 @@
|
||||||
secrets: []
|
secrets: []
|
||||||
register: secrets_4
|
register: secrets_4
|
||||||
|
|
||||||
|
- name: cleanup
|
||||||
|
docker_swarm_service:
|
||||||
|
name: "{{ service_name }}"
|
||||||
|
state: absent
|
||||||
|
diff: no
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- secrets_1 is changed
|
- secrets_1 is changed
|
||||||
|
|
Loading…
Reference in a new issue