Add puppet hook option for --tags
Using --tags allows you to run a puppet manifest and only apply a subset of the catalog. You can specify --tags package for example to only install packages resources for a given manifest. The intent is to use this option alongside of the TripleO docker work to selectively control what parts of a puppet manifest get executed in a container. Change-Id: Ic8b54c89e62cbe5074f256e29e10f59aa2ab0aae
This commit is contained in:
parent
4d789c4b75
commit
a6ebf0c1ef
|
@ -8,3 +8,5 @@ Hook Options:
|
|||
use_facter: default True. Set to True to pass puppet inputs via Facter
|
||||
use_hiera: default False. Set to True to pass puppet inputs via Hiera
|
||||
modulepath: If set, puppet will use this filesystem path to load modules
|
||||
tags: If set, puppet will use the specified value(s) to apply only a
|
||||
subset of the catalog for a given manifest.
|
||||
|
|
|
@ -60,6 +60,7 @@ def main(argv=sys.argv):
|
|||
use_hiera = c['options'].get('enable_hiera', False)
|
||||
use_facter = c['options'].get('enable_facter', True)
|
||||
modulepath = c['options'].get('modulepath')
|
||||
tags = c['options'].get('tags')
|
||||
|
||||
facts = {}
|
||||
hiera = {}
|
||||
|
@ -103,6 +104,9 @@ def main(argv=sys.argv):
|
|||
if modulepath:
|
||||
cmd.insert(-1, '--modulepath')
|
||||
cmd.insert(-1, modulepath)
|
||||
if tags:
|
||||
cmd.insert(-1, '--tags')
|
||||
cmd.insert(-1, tags)
|
||||
log.debug('Running %s %s' % (env_debug, ' '.join(cmd)))
|
||||
try:
|
||||
subproc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||
|
|
|
@ -161,6 +161,7 @@ class HookPuppetTest(common.RunScriptTest):
|
|||
modulepath = self.working_dir.join()
|
||||
data = copy.deepcopy(self.data)
|
||||
data['options']['modulepath'] = modulepath
|
||||
data['options']['tags'] = 'package,file'
|
||||
returncode, stdout, stderr = self.run_cmd(
|
||||
[self.hook_path], self.env, json.dumps(data))
|
||||
|
||||
|
@ -184,6 +185,8 @@ class HookPuppetTest(common.RunScriptTest):
|
|||
'--detailed-exitcodes',
|
||||
'--modulepath',
|
||||
modulepath,
|
||||
'--tags',
|
||||
'package,file',
|
||||
puppet_script
|
||||
],
|
||||
state['args'])
|
||||
|
|
Loading…
Reference in New Issue