From 42a38f91415de6ec0fe5e3981b4faf4225cbb1bc Mon Sep 17 00:00:00 2001 From: "Vince v. Oosten" Date: Wed, 8 Jun 2016 15:39:34 +0200 Subject: [PATCH] move environment variable gathering to end of __init__() (#3890) * This moves the lines in the code that parse the `env` and `env_file` options for docker to the end of the `__init__()` function. This is needed because the `_check_capabilites` function needs both a working `self.client` and a proper `self.docker_py_versioninfo`. `_check_capabilities` is used by `ensure_capabilities` which is, in turn, used by `get_environment` This means that before this commit, the environment variables could not be loaded because both `self.client` and `self.docker_py_versioninfo` were not set at that time. This commit fixes that by putting the environment variable parsing after those two. * This moves the lines in the code that parse the `env` and `env_file` options for docker to the end of the `__init__()` function. This is needed because the `_check_capabilites` function needs both a working `self.client` and a proper `self.docker_py_versioninfo`. `_check_capabilities` is used by `ensure_capabilities` which is, in turn, used by `get_environment` This means that before this commit, the environment variables could not be loaded because both `self.client` and `self.docker_py_versioninfo` were not set at that time. This commit fixes that by putting the environment variable parsing after those two. --- lib/ansible/modules/cloud/docker/_docker.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/_docker.py b/lib/ansible/modules/cloud/docker/_docker.py index 24b826f8673..0291355858e 100644 --- a/lib/ansible/modules/cloud/docker/_docker.py +++ b/lib/ansible/modules/cloud/docker/_docker.py @@ -749,10 +749,6 @@ class DockerManager(object): if self.module.params.get('links'): self.links = self.get_links(self.module.params.get('links')) - env = self.module.params.get('env', None) - env_file = self.module.params.get('env_file', None) - self.environment = self.get_environment(env, env_file) - self.ulimits = None if self.module.params.get('ulimits'): self.ulimits = [] @@ -851,7 +847,11 @@ class DockerManager(object): self.docker_py_versioninfo = get_docker_py_versioninfo() - def _check_capabilties(self): + env = self.module.params.get('env', None) + env_file = self.module.params.get('env_file', None) + self.environment = self.get_environment(env, env_file) + + def _check_capabilities(self): """ Create a list of available capabilities """