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