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
37efe6f243
commit
81c78630fc
|
@ -8,3 +8,5 @@ Hook Options:
|
||||||
use_facter: default True. Set to True to pass puppet inputs via Facter
|
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
|
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
|
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_hiera = c['options'].get('enable_hiera', False)
|
||||||
use_facter = c['options'].get('enable_facter', True)
|
use_facter = c['options'].get('enable_facter', True)
|
||||||
modulepath = c['options'].get('modulepath')
|
modulepath = c['options'].get('modulepath')
|
||||||
|
tags = c['options'].get('tags')
|
||||||
|
|
||||||
facts = {}
|
facts = {}
|
||||||
hiera = {}
|
hiera = {}
|
||||||
|
@ -103,6 +104,9 @@ def main(argv=sys.argv):
|
||||||
if modulepath:
|
if modulepath:
|
||||||
cmd.insert(-1, '--modulepath')
|
cmd.insert(-1, '--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)))
|
log.debug('Running %s %s' % (env_debug, ' '.join(cmd)))
|
||||||
try:
|
try:
|
||||||
subproc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
subproc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||||
|
|
|
@ -161,6 +161,7 @@ class HookPuppetTest(common.RunScriptTest):
|
||||||
modulepath = self.working_dir.join()
|
modulepath = self.working_dir.join()
|
||||||
data = copy.deepcopy(self.data)
|
data = copy.deepcopy(self.data)
|
||||||
data['options']['modulepath'] = modulepath
|
data['options']['modulepath'] = modulepath
|
||||||
|
data['options']['tags'] = 'package,file'
|
||||||
returncode, stdout, stderr = self.run_cmd(
|
returncode, stdout, stderr = self.run_cmd(
|
||||||
[self.hook_path], self.env, json.dumps(data))
|
[self.hook_path], self.env, json.dumps(data))
|
||||||
|
|
||||||
|
@ -184,6 +185,8 @@ class HookPuppetTest(common.RunScriptTest):
|
||||||
'--detailed-exitcodes',
|
'--detailed-exitcodes',
|
||||||
'--modulepath',
|
'--modulepath',
|
||||||
modulepath,
|
modulepath,
|
||||||
|
'--tags',
|
||||||
|
'package,file',
|
||||||
puppet_script
|
puppet_script
|
||||||
],
|
],
|
||||||
state['args'])
|
state['args'])
|
||||||
|
|
Loading…
Reference in New Issue