Besides static file inventories, Ansible can use custom scripts to dynamically generate inventories or access other sources, for example a CMDB or a system management server – like Red Hat Satellite.
Luckily, Nick Strugnell has already written a custom script to use Satellite as an inventory source in Ansible.
After checking out the git, the hammer.ini
needs to be adjusted: at least host
, username
, password
and organization
must be adjusted.
Afterwards, the script can be invoked directly to show the available hosts:
$ ansible -i ~/Github/ansible-satellite6/satellite-inventory.py all --list-hosts argon.example.com satellite-server.example.com helium.example.com ...
This works with ansible
CLI and playbook calls:
$ ansible-playbook -i ~/Github/ansible-satellite6/satellite-inventory.py apache-setup.yml PLAY [apache setup] *********************************************************** GATHERING FACTS *************************************************************** ...
The script works quite well – as long as the certificate you use on the Satellite server is trusted. Otherwise the value for self.ssl_verify
must be set to False
. Besides, it is a nice and simple way to access already existing inventory stores. This is important because Ansible is all about integration, and not about “throwing away and making new”.
May it be possible not to show these blog posts on the KDE-related planetkde.org site? I don’t want to offend anyone, it is just not related.
The “issue” is already fixed 🙂
You are not offending. I actually already had the discussion with the KDE team to not include my entire blog on planetkde, but for example only the “KDE” category. Last time (already quite some time ago) it wasn’t worth the effort since I posted a lot of KDE content anyway, but that has declined recently. I will ask again =)
Thank you! 🙂
We’re maintaining a (hopefully!) better inventory here – it’s got some community usage and we hope to make it the ‘trusted’ solution for providing Satellite info to Ansible.
http://github.com/theforeman/foreman_ansible_inventory
Check it out 🙂
Looks pretty neat. I especially like the idea to have Foreman parameters included as variables, that’s certainly very helpful!
Have you thought about getting it into the contrib directory of Ansible? https://github.com/ansible/ansible/tree/devel/contrib/inventory
Thanks for sharing!
Getting SSL3_GET_SERVER_CERTIFICATE:certificate verify failed.
I added hammer.ini with self.ssl_verify=False