How to upload facts and reports to foreman for ansible hosts

Hello folks,

We onboard hosts to foreman using ansible callback plugin, it takes all facts and reports of hosts uploaded to foreman but when we run playbooks next time says uptime or ping against hosts, job got executed but no facts and reports are uploaded to foreman.

Do we need to update any parameters in foreman ansible.cfg file to get facts whenever we run play books? how do we get facts and reports updated into foreman like puppet-agent?

Is there any way to update the single fact or push fact to foreman which is using ansible callback plugin?

Can we run ping ourselves via say bash scripts and push specific fact to foreman via API ? Because ansible_ping requires ssh connections to open up and this may leads to load on server in case of connecting 100 machines at once?

Any pointers or documentations to this would be helpful.

  • updating specific or single fact per host via API

  • How to secure API’s , i mean does the user logins also have API permissions? Can we limit API to API specific user created?

Thanks in Advance

The /usr/share/foreman-proxy/.ansible.cfg has the callback enabled for me, so as long as the job gathers facts it should report them.

This would mean all facts, so I am not aware of the possibility for only one or specific facts.

Remote execution does not run all in parallel. But I do not find the limit at the moment.

API access is not a different or specific permission.

1 Like

@Dirk - Thanks for the reply.
Here is my config file /usr/share/foreman-proxy/.ansible.cfg.
Do i need to add any parameters to the file to collect facts whenever we run play books against hosts? For the first time it is on boarding and uploading facts into foreman but not next runs.

callback_whitelist = foreman
local_tmp = /tmp
host_key_checking = False
stdout_callback = yaml
roles_path = /etc/ansible/roles:/usr/share/ansible/roles

[callback_foreman]
url = https://nm-foreman.mydomain.com
ssl_cert = /etc/puppetlabs/puppet/ssl/certs/nm-foreman.mydomain.com.pem
ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/nm-foreman.mydomain.com.pem
verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem 
###verify_certs = /etc/ssl/certs/ca-bundle.crt

[ssh_connection]
ssh_args = -o ProxyCommand=none -C -o ControlMaster=auto -o ControlPersist=60s ```

The configuration looks correct.

I am not sure if you are just misguided by how Foreman is presenting the values. The reported_at is only updated if a value is changed. When you look at a constantly changing value like ansible_memfree_mb it should be changing or at /config_reports a report should be shown.

@Dirk – I have recently added 10 hosts about 16 hours ago into foreman using ansible callback plugin.
After addition of hosts, i have run ansible play books against hosts every 1 hour but no facts and reports are updated in foreman GUI – Uploaded screenshots.

It is updating facts and reports in foreman GUI only on first run not on every playbook run.

Thanks