Hi,
I am currently using the api to see what playbooks are scheduled .
From this api call I get an inventory and if it is defined a limit. I tought given these 2 parameters it would be easy to get a list of hosts (via the api) that shows the hosts that match the limit and the inventory.
This seems quite hard. The only way (in theory) I think I could get this to launch a playbook with something like
- name: show all the hosts matching the pattern, i.e. all but the group www
when: ansible_limit is defined debug: msg: “{{ item }}” with_inventory_hostnames: - {{ansible_limit }}
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/inventory_hostnames_lookup.html
This would be the scenario
Query schedules
for every schedule get the inventory and limit
for every inventory and limit launch a template with inventory and limit that prints the hostnames using the with_inventory_hostnames module.
This is quit inefficient so I hope there is a better way to filter out the hosts of a template when the limit is set.
So am I on the right (but painfully tedious) way or have I missed a crucial part in the api documentation?
In short: How do I get a filtered inventory given an ansible limit parameter via the API
kind regards,