Foreman: Import ansible roles from roles directory (/etc/ansible/roles)

Hey guys,

how is it possible to import local ansible roles? The documentation says the page should look like this, but I only see this site, which doesn’t offer me to import any roles. Ansible is installed along with foreman on the same host, and foreman has read-access to the ansible directory (/etc/ansible).

Foreman and Ansible versions: Foreman 1.20.1, Ansible 2.5.5

[1] https://www.theforeman.org/static/images/plugins/foreman_ansible/ansible_roles_index.png
[2] https://imgur.com/a/JwgFUvW

I also tried to import the roles via the smart_proxy. I installed it and verified the correctness via curl:

root@ansible [~]# curl -i http://localhost:8000/features; echo
HTTP/1.1 200 OK 
Content-Type: application/json
Content-Length: 18
X-Content-Type-Options: nosniff
Server: foreman-proxy/1.21.0-develop
Date: Tue, 15 Jan 2019 09:30:09 GMT
Connection: Keep-Alive

["ansible","logs"]
root@ansible [~]# curl -i http://localhost:8000/ansible/roles; echo
HTTP/1.1 200 OK 
Content-Type: text/html;charset=utf-8
Content-Length: 15
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Server: foreman-proxy/1.21.0-develop
Date: Tue, 15 Jan 2019 09:30:15 GMT
Connection: Keep-Alive

["alpine-base"]
root@ansible [~]#

It works! But when I add the smart proxy to foreman, it only shows the feature “logs”. The ansible feature gets completely ignored. Any ideas?

Cheers,
Marco

I could solve the problem with the help from tbrisker and oprazak from IRC: I forgot to execute the db:seed and db:migrate tasks:

foreman-rake db:migrate
foreman-rake db:seed
# OR for people who installed from source:
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake db:seed

After executing these commands I was able to import the roles and variables! Be sure to reload the “Configure->Ansible->Roles” page – clear the browser cache if needed.

Cheers,
Marco

1 Like

Make sure the smart proxy ansible config listens on both http and https. Iirc it’s “Enabled” key.