Skip to content

Instantly share code, notes, and snippets.

May 11 04:42:41 u2 uwsgi: organization: root
May 11 04:42:41 u2 uwsgi: project: python
May 11 04:42:41 u2 uwsgi: branch: master
May 11 04:42:41 u2 uwsgi: tag: deploy_master
May 11 04:42:46 u2 uwsgi: payload: {"minionid": "MacBook-Pro.local", "name": "python", "target": "/Users/quanta/tmp/python", "url": "gitlab@q-git.robotinfra.c
om:root/python.git", "user": "quanta", "homepage": "https://q-git.robotinfra.com/root/python", "description": ""}
May 11 04:42:46 u2 sudo: root : TTY=unknown ; PWD=/etc/uwsgi/apps-enabled ; USER=root ; COMMAND=/usr/local/bin/salt_fire_event.py -p {"minionid": "MacBook
-Pro.local", "name": "python", "target": "/Users/quanta/tmp/python", "url": "gitlab@q-git.robotinfra.com:root/python.git", "user": "quanta", "homepage": "http
s://q-git.robotinfra.com/root/python", "description": ""} -t deploy_master
May 11 04:42:51 u2 uwsgi: TypeError
#!/usr/bin/env python
import os
import json
import salt.client
import salt.syspaths as syspaths
def application(environ, start_response):
length = environ.get('CONTENT_LENGTH', '0')
*** Operational MODE: single process ***
Traceback (most recent call last):
File "gitlab_salt_event.py", line 5, in <module>
import salt.client
ImportError: No module named salt.client
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 82683, cores: 1)
#!/usr/bin/env python
import os
import json
import salt.client
import salt.syspaths as syspaths
def application(environ, start_response):
length = environ.get('CONTENT_LENGTH', '0')
[DEBUG ] Compiling reactions for tag deploy_master
Process Reactor-4:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/salt/utils/event.py", line 529, in run
chunks = self.reactions(data['tag'], data['data'], reactors)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/salt/utils/event.py", line 505, in reactions
high.update(self.render_reaction(fn_, tag, data))
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/salt/utils/event.py", line 455, in render_reaction
python:
deploy_master:
minionid: MacBook-Pro.local
target: /Users/quanta/tmp/python
user: quanta
{%- set project_name = data['data']['name'] %}
{%- set project_url = data['data']['url'] %}
{%- set branch = data['tag'][7:] %}
{% if data['id'] == 'MacBook-Pro.local' %}
git_pull:
cmd.state.single:
- tgt: 'MacBook-Pro.local'
- arg:
- git.latest
elif 'key_url' in kwargs:
key_url = kwargs['key_url']
cmd = 'wget -q -O- "{0}" | gpg --no-default-keyring --keyring {1}/trustedkeys.gpg --import'.format(key_url, gnupghome)
ret = __salt__['cmd.run_all'](cmd, **kwargs)
if ret['retcode'] != 0:
raise CommandExecutionError(
'Error: key retrieval failed: {0}'.format(ret['stderr'])
)
```
/etc/cron.d/passive-checks:
file:
- append
- text: |
*/5 * * * * nagios output=$(/usr/lib/nagios/plugins/check_procs -c 1:1 -C rsyslogd -u syslog); return_code=$?; printf "%s\t%s\t%s\t%s\n" "q-mail" "rsyslogd_procs" "$return_code" "$output" | /usr/local/nagios/bin/py_send_nsca -H 10.134.151.217 -c /etc/send_nsca.conf
*/5 * * * * nagios output=$(/usr/lib/nagios/plugins/check_procs -c 1:1 -C rsyslogd -u syslog); return_code=$?; printf "%s\t%s\t%s\t%s\n" "q-mail" "rsyslogd_procs" "$return_code" "$output" | /usr/local/nagios/bin/py_send_nsca -H 10.134.185.197 -c /etc/send_nsca.conf
```
@quantonganh
quantonganh / rsyslog.nrpe
Created January 16, 2014 04:58
Calling a macro in sls file
{%- for state in pillar['monitoring']['states'] -%}
{%- for name in salt['monitoring.discover_checks_passive'](state) %}
/etc/cron.d/passive-checks:
file:
- append
- text: |
{{ passive_check(state, name) }}
{%- endfor -%}
{%- endfor %}