diff --git a/_runners/handle_minion_data.py b/_runners/handle_minion_data.py new file mode 100644 index 0000000..222a70e --- /dev/null +++ b/_runners/handle_minion_data.py @@ -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