Explicity set --check and --diff in kolla-ansible
Kolla Ansible no longer supports appending the content of the EXTRA_OPTS environment variable to the ansible-playbook command. Kolla Ansible now supports --check and --diff as explicit CLI arguments, so explicitly pass them into kolla-ansible. Closes-Bug: #2123834 Change-Id: Ia91e5539f4338c8209fbe92739bce916c10b2b7a Signed-off-by: Matt Anson <matta@stackhpc.com>
This commit is contained in:
committed by
Pierre Riteau
parent
d6273899b4
commit
f5a5ddb043
@@ -172,6 +172,10 @@ def build_args(parsed_args, command, inventory_filename, extra_vars=None,
|
||||
cmd += ["--tags", ",".join(all_tags)]
|
||||
if parsed_args.list_tasks:
|
||||
cmd += ["--list-tasks"]
|
||||
if parsed_args.check:
|
||||
cmd += ["--check"]
|
||||
if parsed_args.diff:
|
||||
cmd += ["--diff"]
|
||||
if extra_args:
|
||||
cmd += extra_args
|
||||
return cmd
|
||||
@@ -191,14 +195,6 @@ def _get_environment(parsed_args):
|
||||
ansible_cfg_path = os.path.join(parsed_args.config_path, "ansible.cfg")
|
||||
if utils.is_readable_file(ansible_cfg_path)["result"]:
|
||||
env.setdefault("ANSIBLE_CONFIG", ansible_cfg_path)
|
||||
# kolla-ansible allows passing additional arguments to ansible-playbook via
|
||||
# EXTRA_OPTS.
|
||||
if parsed_args.check or parsed_args.diff:
|
||||
extra_opts = env.setdefault("EXTRA_OPTS", "")
|
||||
if parsed_args.check and "--check" not in extra_opts:
|
||||
env["EXTRA_OPTS"] += " --check"
|
||||
if parsed_args.diff and "--diff" not in extra_opts:
|
||||
env["EXTRA_OPTS"] += " --diff"
|
||||
return env
|
||||
|
||||
|
||||
|
||||
@@ -77,9 +77,10 @@ class TestCase(unittest.TestCase):
|
||||
"-e", "ev_name1=ev_value1",
|
||||
"--limit", "'host1:host2'",
|
||||
"--tags", "tag1,tag2",
|
||||
"--check", "--diff"
|
||||
]
|
||||
expected_cmd = " ".join(expected_cmd)
|
||||
expected_env = {"EXTRA_OPTS": " --check --diff"}
|
||||
expected_env = {}
|
||||
mock_run.assert_called_once_with(expected_cmd, shell=True, quiet=False,
|
||||
env=expected_env)
|
||||
|
||||
@@ -119,10 +120,10 @@ class TestCase(unittest.TestCase):
|
||||
"--limit", "'host1:host2'",
|
||||
"--skip-tags", "tag3,tag4",
|
||||
"--tags", "tag1,tag2",
|
||||
"--check", "--diff"
|
||||
]
|
||||
expected_cmd = " ".join(expected_cmd)
|
||||
expected_env = {"EXTRA_OPTS": " --check --diff",
|
||||
"KAYOBE_VAULT_PASSWORD": "test-pass"}
|
||||
expected_env = {"KAYOBE_VAULT_PASSWORD": "test-pass"}
|
||||
expected_calls = [
|
||||
mock.call(["which", "kayobe-vault-password-helper"],
|
||||
check_output=True, universal_newlines=True),
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes ``--check`` and ``--diff`` CLI arguments not being passed into
|
||||
Kolla Ansible commands.
|
||||
`LP#2123834 <https://bugs.launchpad.net/kayobe/+bug/2123834>`__
|
||||
Reference in New Issue
Block a user