mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Add a function to one off a state call
This commit is contained in:
parent
9b4af6d12c
commit
5d136a9f61
@ -151,3 +151,22 @@ def show_masterstate():
|
||||
'''
|
||||
st_ = salt.state.RemoteHighState(__opts__, __grains__)
|
||||
return st_.compile_master()
|
||||
|
||||
def single(fun=None, **kwargs):
|
||||
'''
|
||||
Execute a single state function with the named kwargs
|
||||
|
||||
CLI Example::
|
||||
salt '*' state.single pkg.installed name=vim
|
||||
'''
|
||||
if fun:
|
||||
comps = fun.split('.')
|
||||
if len(comps) < 2:
|
||||
return False
|
||||
kwargs.update({'state': comps[0], 'fun': comps[1]})
|
||||
|
||||
st_ = salt.state.State(__opts__)
|
||||
err = st_.verify_data(kwargs)
|
||||
if err:
|
||||
return err
|
||||
return st_.call(kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user