Ansible callback plugin keeps adding new hosts

Hey everyone,

i’ve tried to use ansible to add hosts to foreman with the callback_foreman plugin.
It’s actually working pretty well but everytime a playbook is executed, all addressed hosts are added additionally instead of just updating the facts.
I’d really like to do all the playbook execution stuff on the main ansible node and use foreman just for some graphical listing.

So here is my question: Is there a configuration file to specify the option to just update the facts and not add the same hosts again and again or am i missing something?

Foreman version: 2.5.0

Linux Distribution: Ubuntu 20.04.2 LTS Server

/etc/ansible/ansible.cfg:

[defaults]
callback_whitelist = foreman

[callback_foreman]
url = ‘https://ansible-foreman
ssl_cert = /etc/puppetlabs/puppet/ssl/certs/certificate.pem
ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/private_key.pem
verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem


/etc/foreman-proxy/ansible.cfg

[defaults]
callback_whitelist = theforeman.foreman.foreman
local_tmp = /tmp
host_key_checking = False
stdout_callback = yaml
roles_path = /etc/ansible/roles:/usr/share/ansible/roles

[callback_foreman]
url = ‘https://ansible-foreman
ssl_cert = /etc/puppetlabs/puppet/ssl/certs/certificate.pem
ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/private_key.pem
verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem

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

Thank you in advance!

Nevermind, i solved it already by specifying the correct fqdn name of the hosts, which are addressed by ansibles playbooks.

Cheers

1 Like

Can you elaborate about where you set this? I don’t have the same issue but would like to know why mine “just works”. In my testbed I’ve been adding hosts triggered by Ansible fact gathering.

For the record, there’s also Administer → Settings → Puppet (SIC) → “Create new host when facts are uploaded” that should also apply to Ansible. However you want to make sure you have correct FQDN in your inventory, playbooks and hosts, so that the data match correctly.