From f1175693f6f34a6f925d4567afacbb829ddb4b78 Mon Sep 17 00:00:00 2001 From: Vlad Gusev Date: Sun, 10 Apr 2016 12:14:48 +0300 Subject: [PATCH] system/puppet: add --tags parameter (#1916) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * system/puppet: add --tags parameter --tags [1] is used to apply a part of the node’s catalog. In puppet: puppet agent --tags update,monitoring In ansible: puppet: tags=update,monitoring [1] https://docs.puppetlabs.com/puppet/latest/reference/lang_tags.html#restricting-catalog-runs * Add example of tag usage. * system/puppet: add list type for a tags dict. --- system/puppet.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/system/puppet.py b/system/puppet.py index 0b3210f542a..147cb9a42c1 100644 --- a/system/puppet.py +++ b/system/puppet.py @@ -80,6 +80,12 @@ options: required: false default: None version_added: "2.1" + tags: + description: + - A comma-separated list of puppet tags to be used. + required: false + default: None + version_added: "2.1" execute: description: - Execute a specific piece of Puppet code. It has no effect with @@ -106,6 +112,9 @@ EXAMPLES = ''' # Run puppet using a specific piece of Puppet code. Has no effect with a # puppetmaster. - puppet: execute='include ::mymodule' + +# Run puppet using a specific tags +- puppet: tags=update,nginx ''' @@ -147,6 +156,7 @@ def main(): facter_basename=dict(default='ansible'), environment=dict(required=False, default=None), certname=dict(required=False, default=None), + tags=dict(required=False, default=None, type='list'), execute=dict(required=False, default=None), ), supports_check_mode=True, @@ -211,6 +221,8 @@ def main(): cmd += " --show_diff" if p['environment']: cmd += " --environment '%s'" % p['environment'] + if p['tags']: + cmd += " --tags '%s'" % ','.join(p['tags']) if p['certname']: cmd += " --certname='%s'" % p['certname'] if module.check_mode: @@ -227,6 +239,8 @@ def main(): cmd += " --certname='%s'" % p['certname'] if p['execute']: cmd += " --execute '%s'" % p['execute'] + if p['tags']: + cmd += " --tags '%s'" % ','.join(p['tags']) if module.check_mode: cmd += "--noop " else: