Description of problem: Ansible endpoints from the API docs return 404 when trying to access via apache Version-Release number of selected component (if applicable): 6.4.2 How reproducible: Everytime Steps to Reproduce: 1. curl any ansible API endpoint 2. 3. Actual results: 404 error Expected results: A list of all ansible roles Additional info: # curl -H "Content-Type:application/json" -X GET -s -k -u admin:redhat http://satellite.redhat.com/ansible/api/ansible_roles/ <!DOCTYPE html> <html> <head> <title>The page you were looking for doesn't exist (404)</title> ... From the hammer output we can see this is the correct endpoint being called when using debug mode: # hammer -d ansible roles list .... [ INFO 2019-02-15T23:38:00 API] Server: https://satellite.redhat.com [ INFO 2019-02-15T23:38:00 API] GET /ansible/api/ansible_roles ...
I can't reproduce on my 6.4.2 instance, please upload your version of foreman_ansible package, mine is tfm-rubygem-foreman_ansible-2.2.9-8.el7sat.noarch try also running hammer with --reload-cache. Also check you don't have any default or non-existing organization set in your hammer config. See "hammer defaults list". You'll get 404 if the organization/location does not exist. If that does not help, please provide a reproducer environment.
Ansible API works only with v2. I guess its not bug. # curl -s -X GET -k -u admin:changeme 'https://satelite/ansible/api/v2/ansible_roles/' { "total": 2, "subtotal": 2, "page": 1, "per_page": 20, "search": null, "sort": { "by": null, "order": null }, "results": [{"id":1,"name":"adriagalin.motd","created_at":"2019-03-29 17:41:34 UTC","updated_at":"2019-03-29 17:41:34 UTC"},{"id":2,"name":"RedHatInsights.insights-client","created_at":"2019-03-29 17:41:34 UTC","updated_at":"2019-03-29 17:41:34 UTC"}] } # curl -s -X GET -k -u admin:changeme 'https://satellite/ansible/api/ansible_roles/' <!DOCTYPE html> <html> <head> <title>The page you were looking for doesn't exist (404)</title>
Thanks for looking into this Nikhil, closing as notabug. Please reopen if we misunderstood something.
Hello, API documentation found at http://<SATELLITE>/apidoc/v2.html that appears to be provided by the foreman package shows a list of the following ansible endpoints: Ansible inventories Resource Description POST /api/ansible_inventories/hosts Show Ansible inventory for hosts GET /api/ansible_inventories/hosts Show Ansible inventory for hosts POST /api/ansible_inventories/hostgroups Show Ansible inventory for hostgroups GET /api/ansible_inventories/hostgroups Show Ansible inventory for hostgroups Ansible override values Resource Description POST /ansible/api/ansible_override_values Create an override value for a specific ansible variable DELETE /ansible/api/ansible_override_values/:id Destroy an override value Ansible roles Resource Description GET /ansible/api/ansible_roles/:id Show role GET /ansible/api/ansible_roles List Ansible roles DELETE /ansible/api/ansible_roles/:id Deletes Ansible role PUT /ansible/api/ansible_roles/import Import Ansible roles PUT /ansible/api/ansible_roles/obsolete Obsolete Ansible roles GET /ansible/api/ansible_roles/fetch Fetch Ansible roles available to be imported Ansible variables Resource Description GET /ansible/api/ansible_variables/:id Show variable GET /ansible/api/ansible_variables List Ansible variables DELETE /ansible/api/ansible_variables/:id Deletes Ansible variable POST /ansible/api/ansible_variables Create Ansible variable PUT /ansible/api/ansible_variables/:id Updates Ansible variable PUT /ansible/api/ansible_variables/import Import Ansible variables. This will only import variables for already existing roles, it will not import any new roles PUT /ansible/api/ansible_variables/obsolete Obsolete Ansible variables. This will only obsolete variables for already existing roles, it will not delete any old roles It appears that the inventories section is missing the "ansible" prefix to its calls, along with all ansible calls missing the "v2" prefix to the endpoints. I can confirm it works with ansible and v2 added to the endpoints: # curl -s -X GET -k -u apiuser:redhat https://batman.usersys.redhat.com/ansible/api/v2/ansible_inventories/hosts {"all":{"hosts":[],"vars":{}},"_meta":{"hostvars":{}}}
Created redmine issue https://projects.theforeman.org/issues/29034 from this bug
Upstream bug assigned to ofedoren
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/29034 has been resolved.
Verified with Sat 6.8 snap 6.0. Tried all request types with API endpoints from all ansible-related sections of apidoc (e.g. [0], [1]). They actually return data, not 404 error. [0] curl -H "Content-Type:application/json" -X GET -k -u admin:changeme https://<FQDN>/ansible/api/ansible_inventories/hosts [1] curl -H "Content-Type:application/json" -X POST -k -u admin:changeme https://<FQDN>/ansible/api/ansible_override_values -d '{"ansible_variable_id":"21", "override_value":{"match": "domain=domena", "value": "hodnota"}}'
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Important: Satellite 6.8 release), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2020:4366