Add runner for sending error results over XMPP

This commit is contained in:
Adam Goldsmith 2020-01-16 12:55:34 -05:00
parent b85f96a8f4
commit 29d1ab59f9

View File

@ -0,0 +1,29 @@
import subprocess
import salt.modules.xmpp
def xmpp_errors(recipient, data):
error = False
changes = False
with open('/tmp/whatever', 'w') as f:
f.write(repr(data['return']))
f.write(str(type(data['return'])))
if isinstance(data['return'], dict):
error = not all(result['result'] for result in data['return'].values())
changes = any(result['changes'] for result in data['return'].values())
else:
error = not data['success']
if error or changes:
msg = subprocess.check_output(
["salt-run", "jobs.lookup_jid", data['jid']])
salt.modules.xmpp.send_msg(
recipient, msg.decode(),
jid='salt@adamgoldsmith.name',
password="aewae2goh1Tee2Imahhe8iceika5aoph")
return error