Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
saltpythonapi在minion中运行状态_Python_Salt Stack - Fatal编程技术网

saltpythonapi在minion中运行状态

saltpythonapi在minion中运行状态,python,salt-stack,Python,Salt Stack,我可以使用python api运行我的状态吗 salt-N'test_server'state.sls django这将在我的测试助手中安装django 我可以在python脚本中执行类似的操作吗 import salt.client as client c = client.LocalClient() c.cmd('test_server','django',expr_form='nodegroup',pillar={'status':'TEST'}) 是的,salt客户端API可以实现您想

我可以使用python api运行我的状态吗

salt-N'test_server'state.sls django这将在我的测试助手中安装django

我可以在python脚本中执行类似的操作吗

import salt.client as client
c = client.LocalClient()
c.cmd('test_server','django',expr_form='nodegroup',pillar={'status':'TEST'})

是的,salt客户端API可以实现您想要的功能,您的代码只需稍作更改:

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',  
      )

有关更多详细信息,请参见更新的代码

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'},}
  )

['django',支柱={'status':'TEST'}]这给了我一个错误,列表工作是这样的吗?@AbhilashJoseph可能需要把
支柱
放到kwarg,比如
['django'],kwarg={'支柱:{'status':'TEST'},