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
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). I managed to grab the ansible files mid-inventory update, so I actually have the foreman.yml file and have put it up here. 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.
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
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
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
- … 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 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… 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