Foreman Ansible allows you to import hosts via Ansible, along with facts about these hosts and reports of their playbook runs. This plugin should be compatible with any version of Foreman above 1.8, including 1.8.
Every time you run a playbook or an Ansible module, Foreman will receive facts and a report for the host you have executed it on.
In order to make Ansible send us data from the hosts, we set up a callback on your host that runs Ansible. To do this:
Change your /etc/ansible/ansible.cfg to contain the following options
callback_plugins = ~/.ansible/plugins/callback_plugins/ bin_ansible_callbacks = True
And run this line to download the callback file in the appropriate location
wget https://raw.githubusercontent.com/theforeman/foreman_ansible/master/extras/foreman_callback.py -O ~/.ansible/plugins/callback_plugins/foreman_callback.py
Alternatively, you can find the source for the Ansible callback here and deploy it in your directory of choice.
You can configure it via the following environment variables:
If this is the first plugin you’re installing, please see the plugin repository section to set up the repository first.
To install Foreman Ansible, run the following:
Red Hat based (RHEL, CentOS…)
# yum install tfm-rubygem-foreman_ansible
# yum install rubygem-foreman_ansible
Debian based (Debian, Ubuntu…)
# apt-get install ruby-foreman-ansible
Restarting Foreman might be needed after installing the package.
You can use the dynamic inventories feature in Ansible to make your inventory be Foreman, and have host properties and parameters available as Ansible variables in your manifests.
In Foreman, you should add whatever Ansible hosts you want to submit facts from to the setting
trusted_puppetmaster_hosts. Change it at Administer > Settings, Puppet tab.
If the Foreman setting ‘create_new_host_when_facts_are_uploaded’ is true, and $HOSTNAME doesn’t exist in Foreman, it will autocreate that host in Foreman. If it already exists, it will update the facts.
Similarly, the Foreman setting ‘ignore_puppet_facts_for_provisioning’ is set to false, facts related to interfaces will update the interfaces of $HOSTNAME in Foreman.
No instructions needed! Run ansible on your hosts and the callback will send everything to Foreman automatically. Here’s a quick gif of what registering a new host in Foreman looks like.
Please follow our standard procedures and contacts.
Errors regarding the import of facts and reports will show up on /var/log/foreman/production.log of your Foreman host.
If you find a bug, please file it in Redmine.
See the troubleshooting section in the Foreman manual for more info.
Follow the same process as Foreman for contributing.
Sources at github.com/theforeman/foreman_ansible
Release candidates for Foreman 1.16.0-RC1 are now available, please help testing the new release. Read about all of the changes in the release notes, and follow the quick start to install it.
A new bug fix release for Foreman 1.15 is available. See the Foreman 1.15.6 release notes for more details.