我'm trying to set up a really basic salt-api configuration just to test it out. I' m使用salt-master和 salt-minion 2016.3.0 Boron on Ubuntu 14.04
我正在使用this tutorial,我的配置如下 .
/srv/salt/top.sls
base:
'*':
- reactor
/etc/salt/master.d/reactor.conf
reactor:
- 'salt/netapi/hook/restart':
- /srv/reactor/test.sls
/srv/reactor/test.sls
{% set postdata = data.get('post', {}) %}
{% if postdata.secretkey == "replacethiswithsomethingbetter" %}
test:
local.cmd.run:
- tgt: '{{ postdata.tgt }}'
-arg:
- touch /home/username/test.txt
{% endif %}
我重新启动了主人,如果我运行 salt '*' state.sls reactor ,那么该州的一切都运行正常 . 它所做的只是 touch /home/username/test.txt ,并且在我运行状态时创建了该文件 .
我正在运行以使用API的命令是
curl -H "Accept: application/json" -d tgt='*' -d secretkey="replacethiswithsomethingbetter" -k https://192.168.1.1:8080/hook/services/restart
那个命令返回 {"success": true}
然后我检查了minion,并且文件尚未创建 .
salt-run state.event pretty=True 的输出是
salt/netapi/hook/services/restart {
"_stamp": "2016-06-29T19:30:04.193832",
"body": "",
"headers": {
"Accept": "application/json",
"Content-Length": "46",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "192.168.1.1:8080",
"Remote-Addr": "192.168.1.3",
"User-Agent": "curl/7.35.0"
},
"post": {
"secretkey": "replacethiswithsomethingbetter",
"tgt": "*"
}
}
我确实完成了所有自签名的证书步骤 . 我不是100%确定为什么我需要这些,但它已经完成了,它们被列在rest_cherrypy配置中 .
任何帮助表示赞赏 .
EDIT 1
我编辑了反应堆的东西,因为有一个使用cmd.run或local.cmd.run的例子,位于盐文档中here
它仍然是真的,而不是工作 .