From 6a6b7526fb023519276f8b7e46f4a5dcd08fd665 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Thu, 14 May 2020 14:48:37 -0500 Subject: [PATCH] Ensure playbook execution respects CLI ENV vars This change restores the ability to set environment variables on the CLI to augment or change ansible behaviours. Somewhere along the way, this capability was lost which can have a negative effect on CLI interactions and UX. Change-Id: Ieef1c7a07064a88bee43a1f4d9005007bfeb7c43 Signed-off-by: Kevin Carter --- tripleoclient/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index 79ceafa9a..d031953a1 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -460,7 +460,7 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None, callback_whitelist = ','.join([callback_whitelist, 'profile_tasks']) - env = os.environ.copy() + env = dict() env['ANSIBLE_SSH_ARGS'] = ( '-o UserKnownHostsFile={} ' '-o StrictHostKeyChecking=no ' @@ -590,6 +590,10 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None, if key: env['ANSIBLE_PRIVATE_KEY_FILE'] = key + # NOTE(cloudnull): Re-apply the original environment ensuring that + # anything defined on the CLI is set accordingly. + env.update(os.environ.copy()) + if extra_env_variables: if not isinstance(extra_env_variables, dict): msg = "extra_env_variables must be a dict"