Add support for --skip-tags and --kolla-skip-tags
Allows for skipping tasks with matching tags in both kayobe and kolla-ansible
This commit is contained in:
parent
8b4af4b029
commit
a20b3e07c1
@ -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)]
|
||||
|
@ -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)]
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user