foreman-ansible-modules
foreman-ansible-modules copied to clipboard
Get ansible roles via inventory plugin
SUMMARY
With the ansible inventory plugin I would like to be able to group together in the hosts that have the same ansible role configured.
I can get the list of single hosts that have the ansible role applied with a host filter like this: host_filters: 'ansible_role="namespace.role"'
but that does not include hosts that have the ansible role applied from a host group.
This might be a limitation of the Satellite/Foreman api since the hosts overview in Satellite behaves the same.
Is there perhaps another way I could access this information?
To give you the context: I'm trying to use a ansible role in Satellite that's heavily dependent on ansible inventory groups for various things. Since the way Satellite/Foreman works with Ansible roles / variables is a bit different than Ansible does in general this has proven somewhat challenging but I could work around the issue with the inventory plugin if I could get a list of hosts that have the particular role applied.
ISSUE TYPE
- Feature Idea
I think it would be awesome if the inventory plugin reported back the "foreman_ansible_roles" variable that is created by inventory_creator.rb, which appears to be exposed under /api/hosts/:id/ansible_roles and /api/hostgroups/:id/ansible_roles.