Ansible Dynamic Inventory
I've registered all of my hosts into PatchMon, and assigned them into groups.
It'd be amazing if I could point Ansible at a dynamic inventory plugin that queries patchmon for a list of hosts (and their groups)
https://docs.ansible.com/ansible/latest/dev_guide/developing_inventory.html
Is this something you'd be willing to support? I'm happy contributing to this feature/new repo if accepted?
5 Comments
https://galaxy.ansible.com/ui/repo/published/patchmon/dynamic_inventory/
tested against v1.3.4
I think this is in large part there already. There is an endpoint , /api/v1/hosts/info which returns host info. Probably need to add in host group info which this endpoint currently does not return. I'm going to take a stab at writing the plugin.
I'm going to further research into this.
If anyone else has view on this feature request then do put them forth :)
This is an interesting idea! I would probably use this. Perhaps this could be handled outside of PatchMon though: if there is an API to retrieve all hosts and their groups from PatchMon, one could create a simple script to turn this into the correct syntax for an Ansible inventory

I have a fork of the dynamic inventory going:
https://github.com/mrjoshuap/PatchMon-ansible
It seems to support these and a number additional host variables (with
include_stats)Hostvar
Source
ansible_host/patchmon_ipippatchmon_ididpatchmon_hostname/patchmon_friendly_nameidentity fields
patchmon_os_type/patchmon_os_versionOS
patchmon_status/patchmon_effective_status/patchmon_reporting_statelifecycle / freshness
patchmon_update_stateup_to_date,updates_pending,security_requiredpatchmon_needs_rebootboolean
patchmon_updates_count/patchmon_security_updates_count/patchmon_total_packagespackage counts
patchmon_last_updatelast agent report