From a4f5c2e9934a178e90b26ccd911de12851a4999e Mon Sep 17 00:00:00 2001 From: Tomer Brisker Date: Sat, 15 Feb 2020 15:01:27 +0200 Subject: [PATCH] Post reports to newer Foreman API endpoint (#64955) The `/api/v2/reports` endpoint has been deprecated a long time ago and should no longer be used. This changes to callback to use the correct API endpoint and paramerter. --- lib/ansible/plugins/callback/foreman.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/ansible/plugins/callback/foreman.py b/lib/ansible/plugins/callback/foreman.py index e973dbe827f..2b6a8a0c5e4 100644 --- a/lib/ansible/plugins/callback/foreman.py +++ b/lib/ansible/plugins/callback/foreman.py @@ -202,7 +202,7 @@ class CallbackModule(CallbackBase): metrics["time"] = {"total": int(time.time()) - self.start_time} now = datetime.now().strftime(self.TIME_FORMAT) report = { - "report": { + "config_report": { "host": host, "reported_at": now, "metrics": metrics, @@ -210,11 +210,8 @@ class CallbackModule(CallbackBase): "logs": log, } } - # To be changed to /api/v2/config_reports in 1.11. Maybe we - # could make a GET request to get the Foreman version & do - # this automatically. try: - r = requests.post(url=self.FOREMAN_URL + '/api/v2/reports', + r = requests.post(url=self.FOREMAN_URL + '/api/v2/config_reports', data=json.dumps(report), headers=self.FOREMAN_HEADERS, cert=self.FOREMAN_SSL_CERT,