salt-states/_runners/handle_minion_data.py

30 lines
804 B
Python

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