Unable to discovery Ansible Tower with Cloud Management

Brady Himmelric
Kilo Contributor

I am trying to connect my developer instance of London to my Ansible Tower instance. I am unable to get discovery working after configuring the URL.

 

Failed to execute API - Failed with status code and message: 500: Failed with status code and message: 401: {"detail":"Authentication credentials were not provided. To establish a login session, visit /api/login/."} (ad_hoc:ansible-tower-1.0-Discover; line 63)

7 REPLIES 7

Hi Hardik,

Thanks for the reply, as I am late to see this. I have updated my script with the one you provided, however, I am still not able to obtain a successful discovery. The error that I receive is:

 

Failed to execute API - Failed with status code and message: 500: Failed with status code and message: 401: {"detail":"Authentication credentials were not provided."} (ad_hoc:ansible-tower-1.0-Discover; line 63)

Varshith Kuraga
Tera Guru

Hello,

I'm currently facing similar error

java.lang.RuntimeException: Failed to execute API - Failed with status code and message: 500: TypeError: Cannot convert null to an object. (ad_hoc:ansible-tower-1.0-Discover; line 63). 

Does anyone have any update to fix this issue? Thanks 

Brent Langdon
Tera Contributor

Updating an old post since this one came up when I was hitting similar issues.  For anybody with this issue in 2020...

1) Make sure that the MID Server setting mid.cmp.ansible.api_version is changed from "v1" to "v2".

2) The attached AnsibleTowerAPIBase above is likely based on an older version.  The current version (well in New York and Orlando) has support for Basic Authentication built in.  Basic Authentication needs to be enabled in Ansible Tower (on the Settings > System page).  I think Tower needs to be restarted for this to take affect.

I tweaked my version of AnsibleTowerAPIBase to support using an OAuth token.  To do so I generated a token in Ansible Tower, stored that token in the Password for the Credentials record, and then updated the code block in the _getToken method to:

else if(versionIdentifier <= 0){
 // note: remove or comment out the existing code here
 return "Bearer " + this.towerPassword;
}