Reputation: 1196
Can i run my state using python api ?
salt -N 'test_server' state.sls django this will install django in my test minion
Can i do something like this in python script ?
import salt.client as client
c = client.LocalClient()
c.cmd('test_server','django',expr_form='nodegroup',pillar={'status':'TEST'})
Upvotes: 3
Views: 2500
Reputation: 1196
The Updated code should be
import salt.client as client
c = client.LocalClient()
c.cmd('test_server', # target
'state.sls', # function
['django'], # arg for function
expr_form='nodegroup',
kwarg={'pillar':{'status':'TEST'},}
)
Upvotes: 0
Reputation: 16433
Yes, salt Client API can do what you want, your code just need to change a bit:
import salt.client as client
c = client.LocalClient()
c.cmd('test_server', # target
'state.sls', # function
['django', pillar={'status':'TEST'}], # arg for function
expr_form='nodegroup',
)
see Salt Python client API docs for more detail
Upvotes: 5