salt-api-reactor-formula
salt-api-reactor-formula copied to clipboard
Convert api key to a grain value
Currently Salt reactors can read grains set on a system (not pillars). So it would be good to set the API key as a grain rather than defining in all of the files.
hello madflojo Why the process ID has not changed?
`# netstat -lntp | grep sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 11739/sshd
tcp6 0 0 :::22 :::* LISTEN 11739/sshd
curl -ki https://localhost:8000/hook/services/restart -H "Accept: application/x-yaml" -d tgt='*' -d service="sshd" -d secretkey="replacethiswithsomethingbetter"
HTTP/1.1 200 OK Content-Length: 14 Access-Control-Expose-Headers: GET, POST Vary: Accept-Encoding Server: CherryPy/3.2.2 Allow: POST Access-Control-Allow-Credentials: true Date: Fri, 09 Sep 2016 17:55:46 GMT Access-Control-Allow-Origin: * Content-Type: application/x-yaml Set-Cookie: session_id=aaf289da8488b3f824a01a7afb15a6d5d97ea8a9; expires=Sat, 10 Sep 2016 03:55:46 GMT; Path=/
success: true
[root@yunwei-dev key]# netstat -lntp | grep sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 11739/sshd
tcp6 0 0 :::22 :::* LISTEN 11739/sshd `
@lvs071103 Is the service sshd
or ssh
? Generally the service name is ssh
. If all else fails I'd suggest checking the logs on the master to see what it shows.
@madflojo thanks!
salt master log report Error:
2016-09-10 10:38:41,496 [salt.utils.templates][ERROR ][8311] Rendering exception occurred: Jinja variable 'dict object' has no attribute 'args'
2016-09-10 10:38:41,497 [salt.utils.reactor][ERROR ][8311] Failed to render "/srv/salt/reactor/services/restart.sls":
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/utils/reactor.py", line 68, in render_reaction
data=data)
File "/usr/lib/python2.7/site-packages/salt/state.py", line 304, in render_template
template, self.rend, self.opts['renderer'], **kwargs)
File "/usr/lib/python2.7/site-packages/salt/template.py", line 95, in compile_template
ret = render(input_data, saltenv, sls, **render_kwargs)
File "/usr/lib/python2.7/site-packages/salt/renderers/jinja.py", line 69, in render
**kws)
File "/usr/lib/python2.7/site-packages/salt/utils/templates.py", line 178, in render_tmpl
output = render_str(tmplstr, context, tmplpath)
File "/usr/lib/python2.7/site-packages/salt/utils/templates.py", line 384, in render_jinja_tmpl
buf=tmplstr)
SaltRenderError: Jinja variable 'dict object' has no attribute 'args'
how to fix it ?
salt-call --versions
Salt Version:
Salt: 2016.3.2
Dependency Versions:
cffi: 1.7.0
cherrypy: 3.2.2
dateutil: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.8
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.21.1
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: Not Installed
pycparser: 2.14
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.5 (default, Nov 20 2015, 02:00:19)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.4.1
ZMQ: 4.1.5
System Versions:
dist: centos 7.2.1511 Core
machine: x86_64
release: 3.10.0-327.el7.x86_64
system: Linux
version: CentOS Linux 7.2.1511 Core
@lvs071103 I see now, instead of using service="ssh"
do args="ssh"
. Checkout the example in the README
@madflojo THX The problem is solved.
[root@yunwei-dev salt]# netstat -lntp | grep sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 30659/sshd
tcp6 0 0 :::22 :::* LISTEN 30659/sshd
[root@yunwei-dev salt]# curl -ki https://localhost:8000/hook/services/restart -H "Accept: application/x-yaml" -d tgt='jack_develop' -d args="sshd" -d secretkey="PICKSOMETHINGBETTERPLZKTHX"
HTTP/1.1 200 OK
Content-Length: 14
Access-Control-Expose-Headers: GET, POST
Vary: Accept-Encoding
Server: CherryPy/3.2.2
Allow: POST
Access-Control-Allow-Credentials: true
Date: Sat, 10 Sep 2016 03:22:15 GMT
Access-Control-Allow-Origin: *
Content-Type: application/x-yaml
Set-Cookie: session_id=2b7b2af25b62fccef8d67344f5b740193d7081ef; expires=Sat, 10 Sep 2016 13:22:15 GMT; Path=/
success: true
[root@yunwei-dev salt]# netstat -lntp | grep sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 30859/sshd
tcp6 0 0 :::22 :::* LISTEN 30859/sshd
http://bencane.com/2014/07/17/integrating-saltstack-with-other-services-via-salt-api/ Is it your blog? No updates, I read it, so I made a mistake,thanks again
Ah, I'll have to go through and update that post. Thanks for pointing that out.