From a1c9a8152508785d5babe4ed98eb6a743932a229 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Thu, 21 Jan 2021 17:12:07 +0100 Subject: [PATCH] Quote kolla limit when calling kolla-ansible This is necessary for correctly passing limits containing special characters such as ~ or &. Change-Id: Ia885a226de30d72610dca2eb2f194cef10193095 Story: 2008546 Task: 41651 --- kayobe/kolla_ansible.py | 2 +- kayobe/tests/unit/test_kolla_ansible.py | 4 ++-- releasenotes/notes/quote-kolla-limit-042422e69c008109.yaml | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/quote-kolla-limit-042422e69c008109.yaml diff --git a/kayobe/kolla_ansible.py b/kayobe/kolla_ansible.py index 4171bbaac..38dd35ef9 100644 --- a/kayobe/kolla_ansible.py +++ b/kayobe/kolla_ansible.py @@ -132,7 +132,7 @@ def build_args(parsed_args, command, inventory_filename, extra_vars=None, cmd += ["-e", "%s=%s" % (extra_var_name, extra_var_value)] if parsed_args.kolla_limit or limit: limit_arg = utils.intersect_limits(parsed_args.kolla_limit, limit) - cmd += ["--limit", limit_arg] + cmd += ["--limit", utils.quote_and_escape(limit_arg)] if parsed_args.kolla_skip_tags: cmd += ["--skip-tags", parsed_args.kolla_skip_tags] if parsed_args.kolla_tags or tags: diff --git a/kayobe/tests/unit/test_kolla_ansible.py b/kayobe/tests/unit/test_kolla_ansible.py index ee27442dc..3eced9484 100644 --- a/kayobe/tests/unit/test_kolla_ansible.py +++ b/kayobe/tests/unit/test_kolla_ansible.py @@ -69,7 +69,7 @@ class TestCase(unittest.TestCase): "--configdir", "/path/to/config", "--passwords", "/path/to/config/passwords.yml", "-e", "ev_name1=ev_value1", - "--limit", "host1:host2", + "--limit", "'host1:host2'", "--tags", "tag1,tag2", ] expected_cmd = " ".join(expected_cmd) @@ -105,7 +105,7 @@ class TestCase(unittest.TestCase): "--configdir", "/path/to/config", "--passwords", "/path/to/config/passwords.yml", "-e", "ev_name1=ev_value1", - "--limit", "host1:host2", + "--limit", "'host1:host2'", "--skip-tags", "tag3,tag4", "--tags", "tag1,tag2", ] diff --git a/releasenotes/notes/quote-kolla-limit-042422e69c008109.yaml b/releasenotes/notes/quote-kolla-limit-042422e69c008109.yaml new file mode 100644 index 000000000..d8bfc6943 --- /dev/null +++ b/releasenotes/notes/quote-kolla-limit-042422e69c008109.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes calls to ``kolla-ansible`` when arguments to ``--kolla-limit`` + contain special characters such as ``~`` or ``&``.