diff --git a/states/_runners/process_minion_data.py b/states/_runners/process_minion_data.py index ace7354..2761429 100755 --- a/states/_runners/process_minion_data.py +++ b/states/_runners/process_minion_data.py @@ -5,10 +5,12 @@ import subprocess import json import salt.modules.smtp + ''' -For use with salt reactor + For use with salt reactor ''' + def email_errors(fromaddr, toaddrs, subject, data_str, smtp_server): data = eval(data_str) error = False @@ -30,10 +32,10 @@ def email_errors(fromaddr, toaddrs, subject, data_str, smtp_server): sys.exit() if error or changes: - _js = subprocess.check_output(["salt-run", "--out=json", - "jobs.lookup_jid", data['jid']]) - body = "JobId is %s\n" % (data['jid']) - outdata = json.loads(_js) + js = subprocess.check_output(["salt-run", "--out=json", + "jobs.lookup_jid", data['jid']]) + body = f"JobId is data['jid']\n" + outdata = json.loads(js) nodename = outdata.keys()[0] for i in outdata[nodename]: if not outdata[nodename][i]["result"]: @@ -43,8 +45,10 @@ def email_errors(fromaddr, toaddrs, subject, data_str, smtp_server): salt.modules.smtp.send_msg(recipient=toaddrs, message=data, subject=subject, sender=fromaddr, server=smtp_server, use_ssl=False) + return True + def email_auth(fromaddr, toaddrs, subject, data_str, smtp_server): data = eval(data_str) salt.modules.smtp.send_msg(recipient=toaddrs, message=data,