AWX sync failing; Check Foreman Logs

Problem: When initiating an AWX Inventory Sync to my Foreman instance, it fails. This worked previously, but now does not work anymore. I originally thought a Foreman upgrade caused the break, so spun up a test Foreman host with some test machines in inventory on an older version that I knew worked previously, and it presents the same failure and error. See details below of error messages.

Expected outcome: Inventory syncs into AWX

Foreman and Proxy versions:
3.14; also tested 3.12 and 3.10

Foreman and Proxy plugin versions:

Distribution and version: Foreman on RHEL 9

Other relevant data:
AWX is giving this error, states to “Check Foreman logs” but doesn’t specify which logs to check.

ansible-inventory [core 2.15.13]
  config file = None
  configured module search path = ['/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.11/site-packages/ansible
  ansible collection location = /runner/.ansible/collections:/usr/share/ansible/collections:/usr/share/automation-controller/collections
  executable location = /usr/local/bin/ansible-inventory
  python version = 3.11.11 (main, Feb 10 2025, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-5)] (/usr/bin/python3.11)
  jinja version = 3.1.6
  libyaml = True
No config file found; using defaults
setting up inventory plugins
Loading collection ansible.builtin from 
Loading collection theforeman.foreman from /usr/share/ansible/collections/ansible_collections/theforeman/foreman
Using inventory plugin 'ansible_collections.theforeman.foreman.plugins.inventory.foreman' to process inventory source '/runner/inventory/foreman.yml'
[WARNING]:  * Failed to parse /runner/inventory/foreman.yml with auto plugin:
Error scheduling inventory report on foreman. Please check foreman logs!
  File "/usr/local/lib/python3.11/site-packages/ansible/inventory/manager.py", line 293, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/local/lib/python3.11/site-packages/ansible/plugins/inventory/auto.py", line 59, in parse

tailed the /var/log/foreman/production.log log during a sync that failed and received the following:

[I|app|f7531509] Started GET "/api/v2/status?page=1&per_page=250" for 10.1.194.208 at 2025-04-14 12:23:34 -0500
[I|app|f7531509] Processing by Api::V2::HomeController#status as JSON
[I|app|f7531509]   Parameters: {"page"=>"1", "per_page"=>"250", "apiv"=>"v2"}
[I|app|f7531509] Authorized user AWX(AWX Ansible)
[I|app|f7531509]   Rendered api/v2/home/status.json.rabl (Duration: 0.2ms | Allocations: 68)
[I|app|f7531509] Completed 200 OK in 173ms (Views: 0.8ms | ActiveRecord: 20.1ms | Allocations: 14374)
[I|app|beab4bc1] Started POST "/ansible/api/v2/ansible_inventories/schedule" for 10.1.194.208 at 2025-04-14 12:23:34 -0500
[F|app|beab4bc1]
 beab4bc1 | ActionController::RoutingError (No route matches [POST] "/ansible/api/v2/ansible_inventories/schedule"):
 beab4bc1 |
 beab4bc1 | lib/foreman/middleware/logging_context_request.rb:11:in `call'

Seems to imply the report scheduling route is not being served. Do you see the endpoint in server.com/apidoc Ansible_inventories section?
@ofedoren :eyes:

If I go to /apidocs of my Foreman website, I do not see anything Ansible or Inventories when doing a find for either of those on that page.

Do you see rubygem-foreman_ansible in the " Installed Packages" section on the /about page ?

I don’t see an Installed Packages section. I have:

Smart Proxies - Puppet CA, Puppet, and Logs v 3.14.0
Plugins - foreman_puppet v8.1.1

Is this an upgraded box that stopped working or a new setup? Wonder if the foreman_ansible plugin was installed correctly on your setup. From the documentation: Configuring hosts by using Ansible , you need to have the ansible plugin enabled by the installer.

Both, our prod instance was built over a year ago and has been getting upgraded; 2 test instances were also spun up during troubleshooting this. All are default out of the box Foreman, nothing special or added items. AWX used to bring in the inventory fine previously, but we haven’t used it in 3-4 months, so unsure when it stopped working.

The inventory defaults to using a report template that ships in foreman_ansible to get the inventory these days (since collection version 3.0.0).
Up until collection version 5.1.0 we had a fallback that if this didn’t work (because you didn’t have foreman_ansible installed), you’d get the plain API inventory. In 5.1.0 we changed that, as the replies from the two endpoints differ and you can potentially get different information.

If you explicitly want the old hosts API, please set use_reports_api: false in your inventory configuration in AWX.

Thank you for that information. Using the use_reports_api: false in the inventory configuration in AWX works. I wanted to attempt to use the updated format and installed the foreman_ansible plugin, then removed that variable from my AWX inventory and the sync failed again, even with foreman_ansible plugin 15.0.7 installed.

Can you provide /var/log/foreman/production.log from the time the sync failed?

2025-04-24T07:28:55 [I|app|d3f411d5] Started GET "/api/v2/status?page=1&per_page=250" for 10.1.194.208 at 2025-04-24 07:28:55 -0500
2025-04-24T07:28:55 [I|app|d3f411d5] Processing by Api::V2::HomeController#status as JSON
2025-04-24T07:28:55 [I|app|d3f411d5]   Parameters: {"page"=>"1", "per_page"=>"250", "apiv"=>"v2"}
2025-04-24T07:28:55 [I|app|d3f411d5] Authorized user AWX(AWX Ansible)
2025-04-24T07:28:55 [I|app|d3f411d5]   Rendered api/v2/home/status.json.rabl (Duration: 1.3ms | Allocations: 403)
2025-04-24T07:28:55 [I|app|d3f411d5] Completed 200 OK in 225ms (Views: 5.6ms | ActiveRecord: 36.0ms | Allocations: 21631)
2025-04-24T07:28:55 [I|app|7882cc32] Started POST "/ansible/api/v2/ansible_inventories/schedule" for 10.1.194.208 at 2025-04-24 07:28:55 -0500
2025-04-24T07:28:55 [I|app|7882cc32] Processing by Api::V2::AnsibleInventoriesController#schedule as */*
2025-04-24T07:28:55 [I|app|7882cc32]   Parameters: {"input_values"=>"[FILTERED]", "apiv"=>"v2", "ansible_inventory"=>{"input_values"=>"[FILTERED]"}}
2025-04-24T07:28:55 [I|app|7882cc32]   Rendered api/v2/errors/access_denied.json.rabl within api/v2/layouts/error_layout (Duration: 1.0ms | Allocations: 349)
2025-04-24T07:28:55 [I|app|7882cc32]   Rendered layout api/v2/layouts/error_layout.json.erb (Duration: 1.7ms | Allocations: 617)
2025-04-24T07:28:55 [I|app|7882cc32] Filter chain halted as :authorize rendered or redirected
2025-04-24T07:28:55 [I|app|7882cc32] Completed 403 Forbidden in 26ms (Views: 7.7ms | ActiveRecord: 4.6ms | Allocations: 5799)

Seems your user is not allowed to generate reports. I think there is a pre-canned role for that, but can’t remember exactly.

1 Like

Yes, it appears there was a new role “Ansible Tower Inventory Reader” that was added with the plugin that did the trick. Thank you so much for the help with this.

1 Like