From 2ee64fd50790556d63b11290070400a296e12c13 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 26 Feb 2019 12:46:43 +0100 Subject: [PATCH] docker_swarm: fix idempotency (#52976) * Improve idempotency checking: only consider parameters which are part of the generated spec. * Properly handle rotate_worker_token and rotate_manager_token. (cherry picked from commit 42ae6cdb95060b477ba68a9844a25b3bbeb63b86) --- changelogs/fragments/52895-docker_swarm-labels.yaml | 1 + lib/ansible/modules/cloud/docker/docker_swarm.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelogs/fragments/52895-docker_swarm-labels.yaml b/changelogs/fragments/52895-docker_swarm-labels.yaml index edb0aabec4..4b9793007e 100644 --- a/changelogs/fragments/52895-docker_swarm-labels.yaml +++ b/changelogs/fragments/52895-docker_swarm-labels.yaml @@ -1,2 +1,3 @@ bugfixes: - "docker_swarm - do not crash with older docker daemons (https://github.com/ansible/ansible/issues/51175)." +- "docker_swarm - improve idempotency checking; ``rotate_worker_token`` and ``rotate_manager_token`` are now also used when all other parameters have not changed." diff --git a/lib/ansible/modules/cloud/docker/docker_swarm.py b/lib/ansible/modules/cloud/docker/docker_swarm.py index 3659f26b0d..4ca8bd78cb 100644 --- a/lib/ansible/modules/cloud/docker/docker_swarm.py +++ b/lib/ansible/modules/cloud/docker/docker_swarm.py @@ -353,12 +353,17 @@ class TaskParameters(DockerBaseClass): def compare_to_active(self, other): for k in self.__dict__: - if k in ('advertise_addr', 'listen_addr', 'rotate_worker_token', 'rotate_manager_token', 'spec'): + if k in ('advertise_addr', 'listen_addr', 'force_new_cluster', 'remote_addrs', + 'join_token', 'force', 'rotate_worker_token', 'rotate_manager_token', 'spec'): continue if self.__dict__[k] is None: continue if self.__dict__[k] != other.__dict__[k]: return False + if self.rotate_worker_token: + return False + if self.rotate_manager_token: + return False return True