diff --git a/kayobe/ansible.py b/kayobe/ansible.py index b93d40c02..6c66466a5 100644 --- a/kayobe/ansible.py +++ b/kayobe/ansible.py @@ -55,6 +55,9 @@ def add_args(parser): parser.add_argument("-l", "--limit", metavar="SUBSET", help="further limit selected hosts to an additional " "pattern") + parser.add_argument("--skip-tags", metavar="TAGS", + help="only run plays and tasks whose tags do not match" + "these values") parser.add_argument("-t", "--tags", metavar="TAGS", help="only run plays and tasks tagged with these " "values") @@ -135,6 +138,8 @@ def build_args(parsed_args, playbooks, if parsed_args.limit or limit: limits = [l for l in [parsed_args.limit, limit] if l] cmd += ["--limit", ":&".join(limits)] + if parsed_args.skip_tags: + cmd += ["--skip-tags", parsed_args.skip_tags] if parsed_args.tags or tags: all_tags = [t for t in [parsed_args.tags, tags] if t] cmd += ["--tags", ",".join(all_tags)] diff --git a/kayobe/kolla_ansible.py b/kayobe/kolla_ansible.py index 49ca3269a..9abd15ea2 100644 --- a/kayobe/kolla_ansible.py +++ b/kayobe/kolla_ansible.py @@ -55,6 +55,9 @@ def add_args(parser): parser.add_argument("-kl", "--kolla-limit", metavar="SUBSET", help="further limit selected hosts to an additional " "pattern") + parser.add_argument("--kolla-skip-tags", metavar="TAGS", + help="only run plays and tasks whose tags do not match" + "these values in Kolla Ansible") parser.add_argument("-kt", "--kolla-tags", metavar="TAGS", help="only run plays and tasks tagged with these " "values in Kolla Ansible") @@ -120,6 +123,8 @@ def build_args(parsed_args, command, inventory_filename, extra_vars=None, if parsed_args.kolla_limit or limit: limits = [l for l in [parsed_args.kolla_limit, limit] if l] cmd += ["--limit", ":&".join(limits)] + if parsed_args.kolla_skip_tags: + cmd += ["--skip-tags", parsed_args.kolla_skip_tags] if parsed_args.kolla_tags or tags: all_tags = [t for t in [parsed_args.kolla_tags, tags] if t] cmd += ["--tags", ",".join(all_tags)] diff --git a/kayobe/tests/unit/test_ansible.py b/kayobe/tests/unit/test_ansible.py index ac9e21ab8..4706d9fd6 100644 --- a/kayobe/tests/unit/test_ansible.py +++ b/kayobe/tests/unit/test_ansible.py @@ -109,6 +109,7 @@ class TestCase(unittest.TestCase): "--extra-vars", "ev_name1=ev_value1", "--inventory", "/path/to/inventory", "--limit", "group1:host1", + "--skip-tags", "tag3,tag4", "--tags", "tag1,tag2", "--list-tasks", ] @@ -125,6 +126,7 @@ class TestCase(unittest.TestCase): "--become", "--check", "--limit", "group1:host1", + "--skip-tags", "tag3,tag4", "--tags", "tag1,tag2", "playbook1.yml", "playbook2.yml", diff --git a/kayobe/tests/unit/test_kolla_ansible.py b/kayobe/tests/unit/test_kolla_ansible.py index d12b46709..8edb85d20 100644 --- a/kayobe/tests/unit/test_kolla_ansible.py +++ b/kayobe/tests/unit/test_kolla_ansible.py @@ -83,6 +83,7 @@ class TestCase(unittest.TestCase): "--kolla-extra-vars", "ev_name1=ev_value1", "--kolla-inventory", "/path/to/inventory", "--kolla-limit", "host1:host2", + "--kolla-skip-tags", "tag3,tag4", "--kolla-tags", "tag1,tag2", ] parsed_args = parser.parse_args(args) @@ -95,6 +96,7 @@ class TestCase(unittest.TestCase): "--passwords", "/path/to/config/passwords.yml", "-e", "ev_name1=ev_value1", "--limit", "host1:host2", + "--skip-tags", "tag3,tag4", "--tags", "tag1,tag2", ] expected_cmd = " ".join(expected_cmd)