Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tags argument to puppet.noop and puppet.run #565

Merged
merged 1 commit into from
Jan 24, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions salt/modules/puppet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,47 @@ def _check_puppet():
return __salt__['cmd.has_exec']('puppetd')


def run():
def run(tags=None):
'''
Execute a puppet run and return a dict with the stderr,stdout,return code
etc.
Execute a puppet run and return a dict with the stderr, stdout,
return code, etc. If an argument is specified, it is treated as
a comma separated list of tags passed to puppetd --test --tags:
http://projects.puppetlabs.com/projects/1/wiki/Using_Tags

CLI Example::
CLI Examples::

salt '*' puppet.run

salt '*' puppet.run basefiles::edit,apache::server
'''
if not tags:
cmd = 'puppetd --test'
else:
cmd = 'puppetd --test --tags "{0}"'.format(tags)

if _check_puppet():
return __salt__['cmd.run_all']('puppetd --test')
return __salt__['cmd.run_all'](cmd)
else:
raise CommandNotFoundError("puppetd not available")
raise CommandNotFoundError('puppetd not available')

def noop():
def noop(tags=None):
'''
Execute a puppet noop run and return a dict with the stderr,stdout,return code
etc.
Execute a puppet noop run and return a dict with the stderr, stdout,
return code, etc. If an argument is specified, it is treated as a
comma separated list of tags passed to puppetd --test --noop --tags

CLI Example::

salt '*' puppet.noop

salt '*' puppet.noop web::server,django::base
'''
if not tags:
cmd = 'puppetd --test --noop'
else:
cmd = 'puppetd --test --tags "{0}" --noop'.format(tags)

if _check_puppet():
return __salt__['cmd.run_all']('puppetd --test --noop')
return __salt__['cmd.run_all'](cmd)
else:
raise CommandNotFoundError("puppetd not available")
raise CommandNotFoundError('puppetd not available')