Ansible callbacks from Ansible clients are failing with Loadbalancer URL [502 Bad Gateway]

Solution Verified - Updated -

Environment

  • Ansible Automation Platform 2.x.

Issue

  • Job template callback using Loadbalancer URL failed with error :
curl: (22) The requested URL returned error: 502 Bad Gateway

Resolution

  • Configure the loadbalancer to pass only the Remote Host with IP , not IP:PORT

Root Cause

  • The AAP receives IP:PORT header as Remote Host :
automationcontroller.access.log:[LB IP] - - [23/May/2023:10:25:48 +0200] "POST /api/v2/job_templates/[ID]/callback/ HTTP/1.1" 499 0 "-" "curl/7.61.1" "%H, [IP:PORT]"

Diagnostic Steps

  • Check the nginx logs after calling the job template callback:
# curl -k -f -i -H 'Content-Type:application/json' -XPOST -d '{"host_config_key": "[KEY]"}' \
                  https://[AAP]/api/v2/job_templates/[ID]/callback/

automationcontroller.access.log:[LB IP] - - [23/May/2023:10:25:48 +0200] "POST /api/v2/job_templates/[ID]/callback/ HTTP/1.1" 499 0 "-" "curl/7.61.1" "%H, [IP:PORT]"

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments