# Ansible: Foreman Inventory Source

**URL:** <https://forum.ansible.com/t/ansible-foreman-inventory-source/27950>\
**Category:** Ansible Project\
**Created:** [July 4, 2018, 9:51am UTC](https://forum.ansible.com/t/ansible-foreman-inventory-source/27950 "2018-07-04T09:51:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Woolly](https://avatars.discourse-cdn.com/v4/letter/w/ebca7d/32.png) [@Woolly](https://forum.ansible.com/u/Woolly)\
**Post date:** [July 4, 2018, 9:51am UTC](https://forum.ansible.com/t/ansible-foreman-inventory-source/27950/1 "2018-07-04T09:51:03Z")

</div>

Hi,

Does anyone know how to configure the new Foreman Inventory Source plugin that ships with Ansible 2.6?

The documentation for it is here: [https://docs.ansible.com/ansible/devel/plugins/inventory/foreman.html](https://docs.ansible.com/ansible/devel/plugins/inventory/foreman.html)

But this does not even say which file the parameters are meant to be configured in. I’m guessing the first 4 go in ansible.cfg under the [inventory] heading, but I’m not sure where ‘url’ etc are meant to go.  
My understanding of this plugin is that is will query the Foreman API and populate Ansible’s inventory with the hosts returned by Foreman.

Any help configuring this would be much appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![Varun\_Chopra](https://avatars.discourse-cdn.com/v4/letter/v/54ee81/32.png) [@Varun\_Chopra](https://forum.ansible.com/u/Varun_Chopra)\
**Post date:** [July 5, 2018, 12:09pm UTC](https://forum.ansible.com/t/ansible-foreman-inventory-source/27950/2 "2018-07-05T12:09:02Z")

</div>

Make a config file: foreman.ini and insert those inside that.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 5, 2018, 2:26pm UTC](https://forum.ansible.com/t/ansible-foreman-inventory-source/27950/3 "2018-07-05T14:26:42Z")

</div>

@Varun that is for the inventory script, he is asking for the  
inventory plugin which is different.

@Wooly I'll update docs to add an example, but you just need a yaml  
file that ends in '.foreman.yaml' or '.foreman.yml' with contents as  
follows:

plugin: foreman  
url: http(s)://\<to foreman server\>:\<port\>  
user: \<auth user for foreman\>  
password: \<auth pass\>

---

<div class="post-metadata">

**Author:** ![Woolly](https://avatars.discourse-cdn.com/v4/letter/w/ebca7d/32.png) [@Woolly](https://forum.ansible.com/u/Woolly)\
**Post date:** [July 10, 2018, 9:03am UTC](https://forum.ansible.com/t/ansible-foreman-inventory-source/27950/4 "2018-07-10T09:03:20Z")

</div>

Hi Brian, thanks for the reply. Can you tell me when the plugin is meant to run? Is it at the start of any ansible run/command or does it need calling explicitly?

I have enable\_plugins = foreman in the ansible.cfg file and the plugin file is as required. I’m just not sure how I tell if the plugin is trying to poll foreman or not.

Cheers,  
Woolly

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 10, 2018, 3:23pm UTC](https://forum.ansible.com/t/ansible-foreman-inventory-source/27950/5 "2018-07-10T15:23:51Z")

</div>

Add -i /path/to/my.foreman.yml and it should 'just work'tm. You can  
use -vvv to see it working, otherwise you should get a warning.
