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'
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.
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.