mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add skip_tags option to Puppet module (#6293)
* Add Puppet skip_tags option * Include changelog fragment * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
14b19afc9a
commit
ea8720f572
4 changed files with 39 additions and 2 deletions
|
@ -0,0 +1,3 @@
|
||||||
|
minor_changes:
|
||||||
|
- puppet - add new options ``skip_tags`` to exclude certain tagged resources during a puppet agent or apply (https://github.com/ansible-collections/community.general/pull/6293).
|
||||||
|
|
|
@ -96,6 +96,7 @@ def puppet_runner(module):
|
||||||
confdir=cmd_runner_fmt.as_opt_val("--confdir"),
|
confdir=cmd_runner_fmt.as_opt_val("--confdir"),
|
||||||
environment=cmd_runner_fmt.as_opt_val("--environment"),
|
environment=cmd_runner_fmt.as_opt_val("--environment"),
|
||||||
tags=cmd_runner_fmt.as_func(lambda v: ["--tags", ",".join(v)]),
|
tags=cmd_runner_fmt.as_func(lambda v: ["--tags", ",".join(v)]),
|
||||||
|
skip_tags=cmd_runner_fmt.as_func(lambda v: ["--skip_tags", ",".join(v)]),
|
||||||
certname=cmd_runner_fmt.as_opt_eq_val("--certname"),
|
certname=cmd_runner_fmt.as_opt_eq_val("--certname"),
|
||||||
noop=cmd_runner_fmt.as_func(noop_func),
|
noop=cmd_runner_fmt.as_func(noop_func),
|
||||||
use_srv_records=cmd_runner_fmt.as_map({
|
use_srv_records=cmd_runner_fmt.as_map({
|
||||||
|
|
|
@ -81,6 +81,12 @@ options:
|
||||||
- A list of puppet tags to be used.
|
- A list of puppet tags to be used.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
skip_tags:
|
||||||
|
description:
|
||||||
|
- A list of puppet tags to be excluded.
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
version_added: 6.6.0
|
||||||
execute:
|
execute:
|
||||||
description:
|
description:
|
||||||
- Execute a specific piece of Puppet code.
|
- Execute a specific piece of Puppet code.
|
||||||
|
@ -143,6 +149,8 @@ EXAMPLES = r'''
|
||||||
tags:
|
tags:
|
||||||
- update
|
- update
|
||||||
- nginx
|
- nginx
|
||||||
|
skip_tags:
|
||||||
|
- service
|
||||||
|
|
||||||
- name: Run puppet agent in noop mode
|
- name: Run puppet agent in noop mode
|
||||||
community.general.puppet:
|
community.general.puppet:
|
||||||
|
@ -198,6 +206,7 @@ def main():
|
||||||
environment=dict(type='str'),
|
environment=dict(type='str'),
|
||||||
certname=dict(type='str'),
|
certname=dict(type='str'),
|
||||||
tags=dict(type='list', elements='str'),
|
tags=dict(type='list', elements='str'),
|
||||||
|
skip_tags=dict(type='list', elements='str'),
|
||||||
execute=dict(type='str'),
|
execute=dict(type='str'),
|
||||||
summarize=dict(type='bool', default=False),
|
summarize=dict(type='bool', default=False),
|
||||||
debug=dict(type='bool', default=False),
|
debug=dict(type='bool', default=False),
|
||||||
|
@ -232,11 +241,11 @@ def main():
|
||||||
runner = puppet_utils.puppet_runner(module)
|
runner = puppet_utils.puppet_runner(module)
|
||||||
|
|
||||||
if not p['manifest'] and not p['execute']:
|
if not p['manifest'] and not p['execute']:
|
||||||
args_order = "_agent_fixed puppetmaster show_diff confdir environment tags certname noop use_srv_records"
|
args_order = "_agent_fixed puppetmaster show_diff confdir environment tags skip_tags certname noop use_srv_records"
|
||||||
with runner(args_order) as ctx:
|
with runner(args_order) as ctx:
|
||||||
rc, stdout, stderr = ctx.run()
|
rc, stdout, stderr = ctx.run()
|
||||||
else:
|
else:
|
||||||
args_order = "_apply_fixed logdest modulepath environment certname tags noop _execute summarize debug verbose"
|
args_order = "_apply_fixed logdest modulepath environment certname tags skip_tags noop _execute summarize debug verbose"
|
||||||
with runner(args_order) as ctx:
|
with runner(args_order) as ctx:
|
||||||
rc, stdout, stderr = ctx.run(_execute=[p['execute'], p['manifest']])
|
rc, stdout, stderr = ctx.run(_execute=[p['execute'], p['manifest']])
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,30 @@ TEST_CASES = [
|
||||||
"changed": False,
|
"changed": False,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"skip_tags": ["d", "e", "f"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "puppet_agent_skip_tags_def",
|
||||||
|
"run_command.calls": [
|
||||||
|
(
|
||||||
|
["/testbin/puppet", "config", "print", "agent_disabled_lockfile"],
|
||||||
|
{"environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}, "check_rc": False},
|
||||||
|
(0, "blah, anything", "",), # output rc, out, err
|
||||||
|
),
|
||||||
|
(
|
||||||
|
[
|
||||||
|
"/testbin/timeout", "-s", "9", "30m", "/testbin/puppet", "agent", "--onetime", "--no-daemonize",
|
||||||
|
"--no-usecacheonfailure", "--no-splay", "--detailed-exitcodes", "--verbose", "--color", "0", "--skip_tags", "d,e,f"
|
||||||
|
],
|
||||||
|
{"environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}, "check_rc": False},
|
||||||
|
(0, "", "",), # output rc, out, err
|
||||||
|
),
|
||||||
|
],
|
||||||
|
"changed": False,
|
||||||
|
}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
TEST_CASES_IDS = [item[1]["id"] for item in TEST_CASES]
|
TEST_CASES_IDS = [item[1]["id"] for item in TEST_CASES]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue