From b183eb44643c315a0fbdc0d8d88cdbd221a46e7c Mon Sep 17 00:00:00 2001 From: Dario Zanzico Date: Mon, 10 Dec 2018 09:39:13 +0100 Subject: [PATCH] docker_swarm_service: ensure idempotency when the user parameter is None (#49235) * ensure idempotency for user set to None * Update `user` documentation and add changelog fragment * clarify changelog fragments and parameters documentation * use restructuredtext syntax in changelog fragment --- .../fragments/49235-docker_swarm_service-user-default.yaml | 5 +++++ lib/ansible/modules/cloud/docker/docker_swarm_service.py | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/49235-docker_swarm_service-user-default.yaml diff --git a/changelogs/fragments/49235-docker_swarm_service-user-default.yaml b/changelogs/fragments/49235-docker_swarm_service-user-default.yaml new file mode 100644 index 0000000000..b45227b250 --- /dev/null +++ b/changelogs/fragments/49235-docker_swarm_service-user-default.yaml @@ -0,0 +1,5 @@ +--- +bugfixes: + - 'docker_swarm_service: fails because of default "user: root" (https://github.com/ansible/ansible/issues/49199)' +minor_changes: + - 'docker_swarm_service: use docker defaults for the ``user`` parameter if it is set to ``null``' diff --git a/lib/ansible/modules/cloud/docker/docker_swarm_service.py b/lib/ansible/modules/cloud/docker/docker_swarm_service.py index e7d37cd8ae..822182bc17 100644 --- a/lib/ansible/modules/cloud/docker/docker_swarm_service.py +++ b/lib/ansible/modules/cloud/docker/docker_swarm_service.py @@ -271,7 +271,10 @@ options: user: required: false default: root - description: username or UID + description: + - username or UID. + - "If set to C(null) the image provided value (or the one already + set for the service) will be used" extends_documentation_fragment: - docker requirements: @@ -720,7 +723,7 @@ class DockerService(DockerBaseClass): differences.add('update_order', parameter=self.update_order, active=os.update_order) if self.image != os.image.split('@')[0]: differences.add('image', parameter=self.image, active=os.image.split('@')[0]) - if self.user != os.user: + if self.user and self.user != os.user: differences.add('user', parameter=self.user, active=os.user) if self.dns != os.dns: differences.add('dns', parameter=self.dns, active=os.dns)