Foreman Not Finding Ansible Roles

I am setting up Foreman using the following option:
I have placed a role under this directory but when I try to import the role, Foreman shows the message “No changes in roles detected on hostname”.
If I place the role under /etc/ansible/roles, the import works.
Any idea why this install option doesn’t seem to be working?

Foreman and Proxy versions:
Foreman and Foreman Proxy are at version 1.20.1

Foreman and Proxy plugin versions:
Ansible plugin is at version 2.2.11

Other relevant data:
I doesn’t seem to be adding the roles_path in /etc/foreman-proxy/ansible.cfg, but even adding it manually doesn’t fix the problem.

I think the ansible.cfg actually lives at ~foreman-proxy/.ansible.cfg, try checking if roles_path is set there. Does manually adding it there help?

Sorry for the delay on this. Our infrastructure for deploying foreman has been down for a while and we just got it back up.

roles_path wasn’t set in ~foreman-proxy/.ansible.cfg when I checked; I tried adding it manually, but it didn’t help.

Can you double check the user foreman-proxy can read that directory? Also could you please set debug log level in /etc/foreman-proxy/settings.yml, then restart service foreman-proxy and look at /var/log/foreman-proxy/proxy.log? Ideally capture that when trying to import ansible roles and upload it here.

Also there was a nasty issue fixed recently, in case there were multiple roles_dirs configured and the last directory was empty, it returned empty list so it could be it.

Just one blind guess: Is SELinux enabled? Creating a new toplevel directory like /ansible will generate a context of unlabeled_t which will probably not accessible by Foreman.

I created a symlink to /ansible/roles from /etc/ansible/roles and this actually worked so it’s not a permissions or SELinux issue.

Unfortunately, I cannot import roles at all now because I reinstalled using Foreman 1.21 so I can get the newer Ansible plugin which supports variable import (which I need). The new installation isn’t showing the smart proxy on localhost under Infrastructure->Smart Proxies. Is there a known issue with 1.21?

Also, when I try to create the proxy manually (I didn’t have to do this in 1.20) I get a Only one declaration of a proxy is allowed error.

Is there a known issue with 1.21? Should I open a new topic for this?

Are you logged in as admin? Perhaps the proxy is not assigned to any organization, try switching to “Any organization” context.

Yup… not assigning to the current organization was the problem. Now I feel dumb. Thank you for the help.
Okay, now back to debugging the original issue. I will update when I can.

Thanks for confirmation, it’s actually pretty bad user experience. If there’s single org in the system, resources should be automatically assigned to it.


I set the logging to DEBUG, restarted foreman-proxy, and tried the import. It didn’t pick up any new roles (the ones I already imported with the workaround were available for removal as expected). Here is the output of /var/log/foreman-proxy/proxy.log

2019-02-28T15:30:11 [D] accept:
2019-02-28T15:30:11 [D] Rack::Handler::WEBrick is invoked.
2019-02-28T15:30:11 e7c9070a [I] Started GET /roles
2019-02-28T15:30:11 e7c9070a [I] Finished GET /roles with 200 (0.57 ms)
2019-02-28T15:30:11 [D] close:

@Marek_Hulan I am also facing the same issue as @ethancpace. This is my error log
2021-07-28T13:53:43 [D] Rack::Handler::WEBrick is invoked.
2021-07-28T13:53:43 724235d6 [I] Started GET /ansible/roles
2021-07-28T13:53:43 724235d6 [I] Finished GET /ansible/roles with 200 (0.89 ms)
2021-07-28T13:53:43 [D] close:

Could you kindly help me?

@almond This thread is from over 2 years ago and related to very old versions of Foreman and the ansible plugin. Even if you are facing a similar issue, it is likely not the same issue as described in this thread. Please open a new thread with the issue you are facing.

Already opened. Could you please guide me?

@tbrisker Here’s the link Foreman is not finding ansible roles