From f5a5ddb043248e09461996907dcc6312bd7f7dd0 Mon Sep 17 00:00:00 2001 From: Matt Anson Date: Fri, 12 Sep 2025 20:41:57 +0100 Subject: [PATCH] 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 --- kayobe/kolla_ansible.py | 12 ++++-------- kayobe/tests/unit/test_kolla_ansible.py | 7 ++++--- ...olla-check-diff--extra-opts-03bc183075f59ada.yaml | 6 ++++++ 3 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 releasenotes/notes/kolla-check-diff--extra-opts-03bc183075f59ada.yaml diff --git a/kayobe/kolla_ansible.py b/kayobe/kolla_ansible.py index c06faafc3..7b5c990c9 100644 --- a/kayobe/kolla_ansible.py +++ b/kayobe/kolla_ansible.py @@ -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 diff --git a/kayobe/tests/unit/test_kolla_ansible.py b/kayobe/tests/unit/test_kolla_ansible.py index 23b2eccf8..68ddab221 100644 --- a/kayobe/tests/unit/test_kolla_ansible.py +++ b/kayobe/tests/unit/test_kolla_ansible.py @@ -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), diff --git a/releasenotes/notes/kolla-check-diff--extra-opts-03bc183075f59ada.yaml b/releasenotes/notes/kolla-check-diff--extra-opts-03bc183075f59ada.yaml new file mode 100644 index 000000000..8c418f91a --- /dev/null +++ b/releasenotes/notes/kolla-check-diff--extra-opts-03bc183075f59ada.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes ``--check`` and ``--diff`` CLI arguments not being passed into + Kolla Ansible commands. + `LP#2123834 `__