自定义returners
默认的returners路径在 /srv/salt/_returners
执行 salt ‘*’ saltutil.sync_returners 同步returners到Minion
如增加一个http回传的return
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import requests def returner(ret): """ Print the return data to the terminal to verify functionality """ job_fun = ret["fun"] job_id = ret["jid"] job_retcode = ret.get("retcode", 1) job_success = True if not job_retcode else False data = { "jid": ret["jid"], "name": ret["id"], "success": job_success, "retcode": ret["retcode"], "result": ret["return"], "fun": ret["fun"], } if "fun_args" in ret: data["fun_args"] = ret["fun_args"] if "fun_kwargs" in ret: data["fun_kwargs"] = ret["fun_kwargs"] res = requests.post('http://192.168.31.133:8000/api/lcm/job/salt', json=data) |