Can't import ansible roles

Problem: Can’t import ansible roles

Expected outcome: Roles to be present in COnfigure > Ansible > Roles

Foreman and Proxy versions:

  • foreman-compute-1.18.0-2.el7.noarch
  • foreman-postgresql-1.18.0-2.el7.noarch
  • foreman-selinux-1.18.0-1.el7.noarch
  • tfm-rubygem-foreman_ansible_core-2.1.1-1.fm1_18.el7.noarch
  • foreman-release-scl-5-1.el7.noarch
  • tfm-rubygem-foreman_ansible-2.2.5-1.fm1_18.el7.noarch
  • foreman-1.18.0-2.el7.noarch
  • foreman-vmware-1.18.0-2.el7.noarch
  • tfm-rubygem-foreman_docker-4.1.0-1.fm1_18.el7.noarch
  • tfm-rubygem-foreman_remote_execution_core-1.1.2-2.el7.noarch
  • foreman-installer-1.18.0-1.el7.noarch
  • tfm-rubygem-foreman_remote_execution-1.5.4-1.fm1_18.el7.noarch
  • foreman-debug-1.18.0-2.el7.noarch
  • foreman-release-1.18.0-2.el7.noarch
  • foreman-proxy-1.18.0-1.el7.noarch
  • foreman-cli-1.18.0-2.el7.noarch
  • tfm-rubygem-foreman-tasks-core-0.2.5-1.fm1_18.el7.noarch
  • tfm-rubygem-foreman-tasks-0.13.2-1.fm1_18.el7.noarch

Foreman and Proxy plugin versions:

  • ansible-2.6.2-1.el7.noarch
  • rubygem-smart_proxy_ansible-2.0.3-1.fm1_18.el7.noarch
  • tfm-rubygem-foreman_ansible_core-2.1.1-1.fm1_18.el7.noarch
  • tfm-rubygem-foreman_ansible-2.2.5-1.fm1_18.el7.noarch

Other relevant data:

cat /etc/ansible/ansible.cfg
[defaults]
callback_whitelist = foreman
bin_ansible_callbacks=True
roles_path    = /etc/ansible/roles
[callback_foreman]
url = 'http://f-apps-335.barf1.com'
ssl_cert = /etc/puppetlabs/puppet/ssl/certs/f-apps-335.barf1.com.pem
ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/f-apps-335.barf1.com.pem
verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem

Hi, could you provide a bit more information about the issue? What exactly happens when you try to import the roles? Do you get any kind of error? If so, is there any relevant information in the logs? Or do you just get a message that no new roles were detected?

Hi

I just get the message: “No ansible roles were found in Foreman. If you want to assign roles to your hosts, you have to import them first.”
Do the roles have to have specific permissions?

I’ve checked the logs but I can’t find anything relevant.

Can you show the permissions of files /etc/ansible/roles/* ?

ls -al /etc/ansible/roles/
total 4
drwxr-xr-x 38 root root 4096 Aug  8 17:32 .
drwxr-xr-x  4 root root   84 Aug  9 09:41 ..
drwxrwxr-x 10 root root  135 Aug  8 17:32 3dx
drwxrwxr-x 10 root root  135 Aug  8 17:32 ad
drwxrwxr-x 10 root root  242 Aug  8 17:32 ansible-netdata
drwxrwxr-x  9 root root  136 Aug  8 17:32 ansible-nodejs
drwxrwxr-x 10 root root  135 Aug  8 17:32 auditbeat
drwxrwxr-x  9 root root  118 Aug  8 17:32 cfdstorage
drwxrwxr-x 10 root root  135 Aug  8 17:32 ciara
drwxrwxr-x 10 root root  135 Aug  8 17:32 cmu
drwxrwxr-x 10 root root  135 Aug  8 17:32 cmu-windows
drwxrwxr-x  9 root root  105 Aug  8 17:32 common
drwxrwxr-x 10 root root  135 Aug  8 17:32 dmf
drwxrwxr-x  9 root root  118 Aug  8 17:32 docker
drwxrwxr-x  9 root root  122 Aug  8 17:32 elasticsearch
drwxrwxr-x  9 root root  105 Aug  8 17:32 enginframe
drwxrwxr-x 10 root root  135 Aug  8 17:32 fea
drwxrwxr-x 10 root root  135 Aug  8 17:32 fea-no-ib
drwxrwxr-x  9 root root  122 Aug  8 17:32 filebeat
drwxrwxr-x 10 root root  135 Aug  8 17:32 foreman
drwxrwxr-x 10 root root  135 Aug  8 17:32 jenkins
drwxrwxr-x 10 root root  135 Aug  8 17:32 jenkins-slave
drwxrwxr-x  9 root root  122 Aug  8 17:32 kibana
drwxrwxr-x 10 root root  135 Aug  8 17:32 lsfmaster
drwxrwxr-x 10 root root  135 Aug  8 17:32 metricbeat
drwxrwxr-x 10 root root  135 Aug  8 17:32 moonshot
drwxrwxr-x 10 root root  135 Aug  8 17:32 nanofluidx
drwxrwxr-x 10 root root  135 Aug  8 17:32 prepost
drwxrwxr-x 10 root root  135 Aug  8 17:32 renda
drwxrwxr-x 10 root root  135 Aug  8 17:32 rgs
drwxrwxr-x  4 root root   36 Aug  8 17:32 sao
drwxrwxr-x 10 root root  135 Aug  8 17:32 syseng
drwxrwxr-x 10 root root  135 Aug  8 17:32 torque
drwxrwxr-x 10 root root  135 Aug  8 17:32 vagrant
drwxrwxr-x  9 root root  122 Aug  8 17:32 vdi
drwxrwxr-x 10 root root  135 Aug  8 17:32 vnc
drwxrwxr-x 10 root root  135 Aug  8 17:32 workstation
drwxrwxr-x 10 root root  135 Aug  8 17:32 z840

It looks ok. Do you have log messages in /var/log/foreman/production.log ?
You should see (among others) those lines :

2018-08-09T10:54:56 [I|app|] Started GET "/ansible/ansible_roles/import?proxy=1-foreman01-company-com" for 10.10.0.20 at 2018-08-09 10:54:56 +0200
2018-08-09T10:54:56 [I|app|62d04] Processing by AnsibleRolesController#import as HTML
2018-08-09T10:54:56 [I|app|62d04]   Parameters: {"proxy"=>"1-foreman01-company-com"}
2018-08-09T10:13:33 [I|app|] Started GET "/ansible/ansible_roles" for 172.26.6.80 at 2018-08-09 10:13:33 +0100
2018-08-09T10:13:33 [I|app|09ca4] Processing by AnsibleRolesController#index as HTML
2018-08-09T10:13:33 [I|app|09ca4] Current user: admin (administrator)
2018-08-09T10:13:33 [I|app|09ca4]   Rendering /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-2.2.5/app/views/ansible_roles/welcome.html.erb within layouts/application
2018-08-09T10:13:33 [I|app|09ca4]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-2.2.5/app/views/ansible_roles/welcome.html.erb within layouts/application (3.0ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered layouts/_application_content.html.erb (0.4ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendering layouts/base.html.erb
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_org_switcher.html.erb (0.1ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_user_dropdown.html.erb (1.3ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_topbar.html.erb (2.4ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_vertical_menu.html.erb (3.0ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_vertical_menu.html.erb (1.0ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_vertical_menu.html.erb (2.9ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_vertical_menu.html.erb (2.7ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_vertical_menu.html.erb (2.0ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_vertical_menu.html.erb (2.6ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_vertical_menu.html.erb (1.0ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered home/_navbar.html.erb (18.7ms)
2018-08-09T10:13:33 [I|app|09ca4]   Rendered layouts/base.html.erb (24.0ms)
2018-08-09T10:13:33 [I|app|09ca4] Filter chain halted as :welcome rendered or redirected
2018-08-09T10:13:33 [I|app|09ca4] Completed 200 OK in 36ms (Views: 28.5ms | ActiveRecord: 1.8ms)

Does this help?

Should there be an import button on that page? Because there is none in my setup.

Yes there should be a button.

this is what I have

the button is missing

Are you logged as administrator ?

yes

Go to Infrastructure → Smart Proxies. If your proxy does not have Ansible among features, try refreshing them .

I don’t have ansible there. any idea on how to get it there?

Found it! had to add --enable-foreman-proxy-plugin-ansible to the install.
Thanks very much for the info!

3 Likes