From 8dafacd4e9eb06d768db32bccf08d0172c793300 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 15 Aug 2014 11:03:29 -0500 Subject: [PATCH] Make env param a dict type instead of list Also modifies param type checking code to remove whitespace from around params before splitting them into k=v pairs. Fixes #8199 --- lib/ansible/module_utils/basic.py | 2 +- library/cloud/docker | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 4d32d04ce58..788e64d25c3 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -808,7 +808,7 @@ class AnsibleModule(object): self.fail_json(msg="unable to evaluate dictionary for %s" % k) self.params[k] = result elif '=' in value: - self.params[k] = dict([x.split("=", 1) for x in value.split(",")]) + self.params[k] = dict([x.strip().split("=", 1) for x in value.split(",")]) else: self.fail_json(msg="dictionary requested, could not parse JSON or key=value") else: diff --git a/library/cloud/docker b/library/cloud/docker index eee95435255..23c88e51843 100644 --- a/library/cloud/docker +++ b/library/cloud/docker @@ -411,9 +411,7 @@ class DockerManager: if self.module.params.get('links'): self.links = self.get_links(self.module.params.get('links')) - self.env = None - if self.module.params.get('env'): - self.env = dict(map(lambda x: x.split("=", 1), self.module.params.get('env'))) + self.env = self.module.params.get('env', None) # connect to docker server docker_url = urlparse(module.params.get('docker_url')) @@ -706,7 +704,7 @@ def main(): password = dict(), email = dict(), hostname = dict(default=None), - env = dict(type='list'), + env = dict(type='dict'), dns = dict(), detach = dict(default=True, type='bool'), state = dict(default='running', choices=['absent', 'present', 'running', 'stopped', 'killed', 'restarted']),