From 8715f96af03a6c4b61539af15c380af12ae08c9b Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 9 Oct 2018 19:16:49 +0200 Subject: [PATCH] [2.7] docker_container: don't parse/interpret options if state is 'absent' (#45769) * Don't parse/interpret options if state is 'absent'. (#45700) * Added changelog. --- .../fragments/45700-docker_container-dont-parse-absent.yml | 2 ++ lib/ansible/modules/cloud/docker/docker_container.py | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 changelogs/fragments/45700-docker_container-dont-parse-absent.yml diff --git a/changelogs/fragments/45700-docker_container-dont-parse-absent.yml b/changelogs/fragments/45700-docker_container-dont-parse-absent.yml new file mode 100644 index 00000000000..77a0af6c731 --- /dev/null +++ b/changelogs/fragments/45700-docker_container-dont-parse-absent.yml @@ -0,0 +1,2 @@ +bugfixes: +- "Don't parse parameters and options when ``state`` is ``absent`` (https://github.com/ansible/ansible/pull/45700)." diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index 470c1e2e179..34cc8d4c080 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -753,6 +753,11 @@ class TaskParameters(DockerBaseClass): for key, value in client.module.params.items(): setattr(self, key, value) + # If state is 'absent', parameters do not have to be parsed or interpreted. + # Only the container's name is needed. + if self.state == 'absent': + return + for param_name in REQUIRES_CONVERSION_TO_BYTES: if client.module.params.get(param_name): try: