From 736d270364bef7f773f3f8dd1dcd99376bc395f1 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 17 Jan 2021 17:44:58 +0100 Subject: [PATCH] updated runners --- states/_runners/process_minion_data.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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,