Need help getting ansible callback to work

Host not being added to foreman after running ansible -m setup “hostname” . this is being run from the host running foreman and its the smart-proxy as well.

Expected outcome:
host should be added to foreman

Foreman and Proxy versions:
Foreman 1.18

other version:
ansible-2.6.1-1.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
tfm-rubygem-foreman_remote_execution-1.5.4-1.fm1_18.el7.noarch
foreman-selinux-1.18.0-1.el7.noarch
foreman-installer-1.18.0-1.el7.noarch
foreman-release-scl-5-1.el7.noarch
foreman-proxy-1.18.0-1.el7.noarch
foreman-release-1.18.0-2.el7.noarch
tfm-rubygem-hammer_cli_foreman-0.13.0-1.el7.noarch
tfm-rubygem-foreman_remote_execution_core-1.1.2-2.el7.noarch
foreman-debug-1.18.0-2.el7.noarch
foreman-1.18.0-2.el7.noarch
tfm-rubygem-foreman_ansible-2.2.3-1.fm1_18.el7.noarch
foreman-cli-1.18.0-2.el7.noarch
tfm-rubygem-foreman_ansible_core-2.0.2-1.fm1_18.el7.noarch
foreman-postgresql-1.18.0-2.el7.noarch

OS CentOS 7.5.1804

Contents of /etc/ansible:
[defaults]

remote_tmp = /tmp
local_tmp = /tmp

roles_path = /etc/ansible/roles

callback_whitelist = foreman

[callback_foreman]
url = ‘https://ansible01.localdomain
ssl_cert = /etc/puppetlabs/puppet/ssl/certs/ansible01.localdomain.pem
ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/ansible01.localdomain.pem
verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem

[inventory]

[privilege_escalation]
become=True
become_method=sudo
become_user=root

[paramiko_connection]

[ssh_connection]

[persistent_connection]

[accelerate]

[selinux]

[colors]

[diff]

I’m not seeing anything helpful in the production log even after configuring debug logging.

Hej flaporta,

check that bin_ansible_callbacks=True is set in ansible.cfg as well. In case this still doesn’t execute the callback and doesn’t report to foreman, see if the ansible output gives any error or warning regarding callbacks/plugins.

1 Like

Could you try to run ‘ansible-playbook’ instead, and run a playbook against the host? I’m not 100% sure the callback triggers when you run only a module these days. I don’t see any request being POSTed to Foreman after that, but I do see it after running ‘ansible-playbook’.

1 Like

Hi dLobatog,

Running a playbook did create the host in foreman. I also tried adding bin_ansible_callbacks=True to ansible.cfg and that seemed to work also, which is not a step in the document for systems running ansible version 2.5 or higher so I removed it. We may want to add to the ansible doc that running a play-book now creates the system in foreman instead of running ansible -m setup for systems running ansible 2.5 or higher. I did not see it mentioned hopefully I did not miss it. You guys are doing a terrific job with Foreman so much nicer than Ansible Tower. I appreciate all the quick responses from all you you guys. Thank you.

Hi

I have the same problem as @flaporta.
Can you give me some tips on how to debug this? I also can’t get my roles to show up in foreman.

Thanks

The original issue seems to be resolved. For the roles import, where do you put them? In my case on 1.19 RC2, I needed to install them to /etc/ansible/roles, then I can import them. Error messages or more depth description of the problem could help.