# satellite6\_want\_hostcollection not working

**URL:** <https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [May 13, 2020, 7:27pm UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927 "2020-05-13T19:27:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaleb\_S](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@Kaleb\_S](https://forum.ansible.com/u/Kaleb_S)\
**Post date:** [May 13, 2020, 7:27pm UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927/1 "2020-05-13T19:27:46Z")

</div>

Good day,

I’m trying to synchronize my host collections from Satellite6.6 to AWX 11.2, using Ansible 2.9.7.

I’ve set inventory source variable satellite6\_want\_hostcollections: true, but I get no host collections, and I don’t get any information on why I don’t get any host collections… is there anything I can look at to troubleshoot?

---

<div class="post-metadata">

**Author:** ![James\_D\_Ladd\_Jr](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@James\_D\_Ladd\_Jr](https://forum.ansible.com/u/James_D_Ladd_Jr)\
**Post date:** [May 14, 2020, 5:58am UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927/2 "2020-05-14T05:58:43Z")

</div>

Hi Kaleb,

We recently moved from the foreman script (previously vendored in awx) to the foreman plugin (now included in a foreman collection that awx vendors). I did a quick check and verified that:

- awx passes along the want\_hostcollections option to the plugin, and
- the foreman plugin has support for want\_hostcollections

That’s just a basic sanity check. It doesn’t ensure that the option actually works with the plugin. I’ll do some more digging in the morning to try to see if this is an issue on the awx side or with the plugin itself. Thanks for reporting what you’re seeing.

-Jim

---

<div class="post-metadata">

**Author:** ![Kaleb\_S](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@Kaleb\_S](https://forum.ansible.com/u/Kaleb_S)\
**Post date:** [May 14, 2020, 1:40pm UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927/3 "2020-05-14T13:40:09Z")

</div>

Thank you Jim!

If it helps, I’ve also tried some of the other satellite6\_ options (such as changing the group\_prefix) and that doesn’t seem to take effect either.

If there’s anything I can do to help troubleshoot, or if you need additional information from my setup, please let me know.

Regards,

Kaleb

---

<div class="post-metadata">

**Author:** ![James\_D\_Ladd\_Jr](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@James\_D\_Ladd\_Jr](https://forum.ansible.com/u/James_D_Ladd_Jr)\
**Post date:** [May 14, 2020, 8:44pm UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927/4 "2020-05-14T20:44:15Z")

</div>

Kaleb,

I went back to the old foreman script to see how hostcollections were used there and confirmed that my satellite instance’s hostcollection was being rendered as a group and was populated with the expected instances. I then went back to awx, set `satellite6_want_hostcollections: true` and confirmed that tower also returned the same hostcollection group, populated with the same instances. So, in this case, I’m not able to reproduce the issue.

Could you share the source vars that you’re using? Maybe some other sourcevars are creating issues for the hostcollection option? This is a blind guess, but maybe something interesting will show up.

Also, if you hop over to the API browser and look at the details for the inventory update ([https://tower/api/v2/inventory\_updates/123/](https://tower/api/v2/inventory_updates/123/)), what does ANSIBLE\_COLLECTIONS\_PATHS show you? If you’re using the default setup for the collections we’re pulling down, it should show “/vendor/inventory\_collections”.

I would be curious to see if you run into issues using the new foreman plugin by itself:  
[https://github.com/theforeman/foreman-ansible-modules](https://github.com/theforeman/foreman-ansible-modules)

I looked into the group\_prefix option and _did_ find an issue there. Looks like we have some awx code responsible for bridging some differences between the foreman script and plugin that isn’t taking into account the group\_prefix. Tracking that issue here: [https://github.com/ansible/awx/issues/7031](https://github.com/ansible/awx/issues/7031)

-Jim

---

<div class="post-metadata">

**Author:** ![Kaleb\_S](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@Kaleb\_S](https://forum.ansible.com/u/Kaleb_S)\
**Post date:** [May 15, 2020, 1:22pm UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927/5 "2020-05-15T13:22:55Z")

</div>

Hi Jim,

I’ve gone through a few things… deleting and recreating the Inventory object… my current Source has just a single variable - I’ve taken a screen capture so I don’t miss anything that might be helpful:

 ![sat6 inventory source.png](https://us1.discourse-cdn.com/ansible/original/2X/5/5c2bd058739607f2c9a2d561bd3c1b706df99cd3.png)

I checked the API and you are correct that the ansible\_collections\_path does indeed show /var/lib/awx/vendor/inventory\_collections

How would I go about using the foreman plugin directly without awx? Sorry if that seems a silly question, but I am open to trying anything out that might make this work, as I use host\_collections to help organize my patching and reboot rounds.

I took a look at the bug you created and it may indeed be related… I have checked the container when the inventory update is running, and there is no foreman.ini or anything that seems to reference the want\_hostcollections or the prefix.I’m not sure if the models/inventory.py is responsible for creating that file, or if that’s missing elsewhere… but I think if the .ini file isn’t being created, the foreman plugin might not be getting configured/controlled properly…?

Let me know if there’s anything I can do to help… I am new to python, but am learning. 🙂

Thanks for your help!

Kaleb

---

<div class="post-metadata">

**Author:** ![James\_D\_Ladd\_Jr](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@James\_D\_Ladd\_Jr](https://forum.ansible.com/u/James_D_Ladd_Jr)\
**Post date:** [May 15, 2020, 7:50pm UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927/6 "2020-05-15T19:50:36Z")

</div>

Hi again,

I have a fix up for the group\_prefix issue here: [https://github.com/ansible/awx/pull/7044](https://github.com/ansible/awx/pull/7044)

> my current Source has just a single variable  
> Weird, okay, it’s good to know that we’re just dealing with this one sourcevar, though.

> I have checked the container when the inventory update is running, and there is no foreman.ini or anything

- The foreman inventory plugin uses a foreman.yml file instead of the old foreman.ini file.
- The machinery that is in charge of building the config file and running the job will erase the \*.yml file that’s created _unless_
- … you add `AWX_CLEANUP_PATHS = False` in awx/settings/local\_settings.py
- … after which you could go to the inventory update job, find where it reports the yml file it referenced (e.g. “Parsed /tmp/awx\_12\_cc1ia4mv/foreman.yml”)
- … which, when you open it up inside the container, should look something like [this](https://gist.github.com/jladdjr/22d502323c8d31e15fd7b3538f6b70ec).

Which brings up a good point… are you seeing the job reference foreman.ini or foreman.yml? If you’re seeing the ini file mentioned that likely means that you’re running a pre-2.9 version of ansible, in which case awx falls back to using the inv. script. This is probably the first thing we should have checked up on. Let me know if you’re seeing the ini file referenced.

Back to plugins… the move to plugins really represents a pretty big change in how inventory updates happen. The inventory plugins build on top of an entire plugin framework that ansible laid out a little while ago.

These docs provide an overview of inventory plugins, what they are, and how to use them:  
[https://docs.ansible.com/ansible/latest/plugins/inventory.html](https://docs.ansible.com/ansible/latest/plugins/inventory.html)

… and these docs provide detailed information for the foreman plugin specifically:  
[https://docs.ansible.com/ansible/latest/plugins/inventory/foreman.html](https://docs.ansible.com/ansible/latest/plugins/inventory/foreman.html)

Those docs should give you a good starting point for trying to run your inventory sync using the plugins directly. Roughly speaking, though, you’ll need to:

- hop on ansible 2.9.\* (pre-2.9 may not have good support for collections, 2.10 on the other hand is going through a pretty big refactor right now and may not work)
- use `ansible-galaxy collection install theforeman.foreman` to install the foreman collection
- create a foreman.yml config file, like the one I mentioned [earlier](https://gist.github.com/jladdjr/22d502323c8d31e15fd7b3538f6b70ec)
- … but add in server config info (url, user, password, validate\_certs) - awx omits this from the config (I assume we’re using env vars instead to keep the file free from creds)
- then run `ansible-inventory -i foreman.yml --list`
- which should print your inventory to stdout

> I’m not sure if the models/inventory.py is responsible for creating that file,  
> models/inventory.py does play a major role in building out the contents of foreman.yml, yes. [This method](https://github.com/ansible/awx/blob/devel/awx/main/models/inventory.py#L2598) specifically.

Hope that helps,  
Jim

> **(attachments)**
>
> ![sat6 inventory source.png](https://us1.discourse-cdn.com/ansible/original/2X/5/5c2bd058739607f2c9a2d561bd3c1b706df99cd3.png)

---

<div class="post-metadata">

**Author:** ![Kaleb\_S](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@Kaleb\_S](https://forum.ansible.com/u/Kaleb_S)\
**Post date:** [May 16, 2020, 5:11am UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927/7 "2020-05-16T05:11:21Z")

</div>

Hi Jim,

I’ll reply below to keep the replies together

> Hi again,
> 
> I have a fix up for the group\_prefix issue here: [https://github.com/ansible/awx/pull/7044](https://github.com/ansible/awx/pull/7044)

Awesome!

> > my current Source has just a single variable  
> > Weird, okay, it’s good to know that we’re just dealing with this one sourcevar, though.

Yeah - I’ve got a very basic setup right now… it’ll get more involved with time, but I either need to change my patching / rebooting process or I need to get hostcollections synching so I can use them to segregate my reboot schedules. 🙂

> > I have checked the container when the inventory update is running, and there is no foreman.ini or anything

Sorry - I should have been more specific… I do have a foreman.yml file, but I was seeing foreman.ini referenced everywhere I was looking when I was troubleshooting on my own and assumed that’s what I was missing (specifically from [ansible docs](https://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html#ug-source-satellite)). I managed to grab the ansible files mid-inventory update, so I actually have the foreman.yml file and have put it up [here](https://gist.github.com/Kalsto/cd178a6ffffe0ca35b87c6b210b50d32). Interesting note, though…my version of foreman.yml doesn’t have the want\_hostcollections at all like yours does. I didn’t install the foreman collection manually - just installed awx through a yaml file using oc apply -f inventory.yml and it had the Satellite Inventory available.

> - The foreman inventory plugin uses a foreman.yml file instead of the old foreman.ini file.
> - The machinery that is in charge of building the config file and running the job will erase the \*.yml file that’s created _unless_
> - … you add `AWX_CLEANUP_PATHS = False` in awx/settings/local\_settings.py
> - … after which you could go to the inventory update job, find where it reports the yml file it referenced (e.g. “Parsed /tmp/awx\_12\_cc1ia4mv/foreman.yml”)
> - … which, when you open it up inside the container, should look something like [this](https://gist.github.com/jladdjr/22d502323c8d31e15fd7b3538f6b70ec).

> Which brings up a good point… are you seeing the job reference foreman.ini or foreman.yml? If you’re seeing the ini file mentioned that likely means that you’re running a pre-2.9 version of ansible, in which case awx falls back to using the inv. script. This is probably the first thing we should have checked up on. Let me know if you’re seeing the ini file referenced.

I’m on Openshift 3.11, and awx is running ansible 2.9.7 so I do see it referencing foreman.yml…I just didn’t fully realize that was the correct file for it to be looking for… some of the documentation on docs is still referencing foreman.ini

> Back to plugins… the move to plugins really represents a pretty big change in how inventory updates happen. The inventory plugins build on top of an entire plugin framework that ansible laid out a little while ago.
> 
> These docs provide an overview of inventory plugins, what they are, and how to use them:  
> [https://docs.ansible.com/ansible/latest/plugins/inventory.html](https://www.google.com/url?q=https%3A%2F%2Fdocs.ansible.com%2Fansible%2Flatest%2Fplugins%2Finventory.html&sa=D&sntz=1&usg=AFQjCNHN90_DQ8X0eYWOq7lfWYw8acQvGQ)

Looking at my install, I’ve got a basic ansible.cfg file, so I can definitely see that I haven’t specifically enabled the foreman plugin… is that something I would have to do post-install directly on the container?

I can see in the awx requirements/collections\_requirements.yml that it’s installing theforeman.foreman v0.7.0 but it specifically says more patches are needed… lol Not sure what specifically is meant by that statement. Should I try using v.0.8.0 by modifying the collections\_requirements.yml and re-deploying my containers?

> … and these docs provide detailed information for the foreman plugin specifically:  
> [https://docs.ansible.com/ansible/latest/plugins/inventory/foreman.html](https://docs.ansible.com/ansible/latest/plugins/inventory/foreman.html)

> Those docs should give you a good starting point for trying to run your inventory sync using the plugins directly. Roughly speaking, though, you’ll need to:
> 
> - hop on ansible 2.9.\* (pre-2.9 may not have good support for collections, 2.10 on the other hand is going through a pretty big refactor right now and may not work)

> - use `ansible-galaxy collection install theforeman.foreman` to install the foreman collection

> - create a foreman.yml config file, like the one I mentioned [earlier](https://gist.github.com/jladdjr/22d502323c8d31e15fd7b3538f6b70ec)
> - … but add in server config info (url, user, password, validate\_certs) - awx omits this from the config (I assume we’re using env vars instead to keep the file free from creds)
> - then run `ansible-inventory -i foreman.yml --list`
> - which should print your inventory to stdout
> 
> > I’m not sure if the models/inventory.py is responsible for creating that file,  
> > models/inventory.py does play a major role in building out the contents of foreman.yml, yes. [This method](https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fansible%2Fawx%2Fblob%2Fdevel%2Fawx%2Fmain%2Fmodels%2Finventory.py%23L2598&sa=D&sntz=1&usg=AFQjCNH5ZjhULSE2r45XxnQGJlTIiHVL-g) specifically.

I’m not overly familiar with git… but if I look at the inventory\_as\_dict method in the devel branch vs the [11.2.0 branch](https://github.com/ansible/awx/blob/11.2.0/awx/main/models/inventory.py#L2577)… I see some differences… am I understanding that correctly? am I trying a feature that’s slightly too new in the conversion to using collections and I need to wait for the next version of awx to come out?

> Hope that helps,  
> Jim

You’ve been exceptionally helpful and I appreciate your patience Jim!

Thanks,

Kaleb

---

<div class="post-metadata">

**Author:** ![James\_D\_Ladd\_Jr](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@James\_D\_Ladd\_Jr](https://forum.ansible.com/u/James_D_Ladd_Jr)\
**Post date:** [May 18, 2020, 5:45am UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927/8 "2020-05-18T05:45:45Z")

</div>

> I’m not overly familiar with git… but if I look at the inventory\_as\_dict method in the devel branch vs the [11.2.0 branch](https://github.com/ansible/awx/blob/11.2.0/awx/main/models/inventory.py#L2577) …

Bingo, that’s it. The head of ansible/awx has a fix that isn’t included in the latest awx release. I think you have two options - you could either move up to the tip of devel or wait for the next release.

-Jim

---

<div class="post-metadata">

**Author:** ![Kaleb\_S](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@Kaleb\_S](https://forum.ansible.com/u/Kaleb_S)\
**Post date:** [May 25, 2020, 1:51pm UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927/9 "2020-05-25T13:51:30Z")

</div>

Thanks Jim - your willingness to help me find the (eventual) solution to my problem is greatly appreciated!

Sorry it took a bit to respond…I was offline for a bit. Any idea when the next release is likely to be? I’m not sure I can swing a dev install to my awx right now…

Thank you again,

Kaleb

---

<div class="post-metadata">

**Author:** ![James\_D\_Ladd\_Jr](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@James\_D\_Ladd\_Jr](https://forum.ansible.com/u/James_D_Ladd_Jr)\
**Post date:** [May 26, 2020, 4:21pm UTC](https://forum.ansible.com/t/satellite6-want-hostcollection-not-working/32927/10 "2020-05-26T16:21:13Z")

</div>

Kaleb,

You’re welcome! Not sure when the next release will be. We have the change teed up in the [release notes](https://github.com/ansible/awx/pull/7117/files#diff-4ac32a78649ca5bdd8e0ba38b7006a1e), but that doesn’t necessarily mean the next release will be soon. If you needed the patch now, but couldn’t move to the head of devel, you could also drop in a hotfix of the changes, switching out the specific file that was changed.
