mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Xen orchestra inventory: Added groups, keyed_groups and compose support (#3766)
* Xen orchestra inventory: Added groups, keyed_groups and compose support * Update plugins/inventory/xen_orchestra.py Remove extra params declaration Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
25e80762aa
commit
336f9465cb
2 changed files with 28 additions and 1 deletions
|
@ -69,6 +69,11 @@ simple_config_file:
|
|||
password: xo_pwd
|
||||
validate_certs: true
|
||||
use_ssl: true
|
||||
groups:
|
||||
kube_nodes: "'kube_node' in tags"
|
||||
compose:
|
||||
ansible_port: 2222
|
||||
|
||||
'''
|
||||
|
||||
import json
|
||||
|
@ -165,6 +170,12 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||
'hosts': self.get_object('host'),
|
||||
}
|
||||
|
||||
def _apply_constructable(self, name, variables):
|
||||
strict = self.get_option('strict')
|
||||
self._add_host_to_composed_groups(self.get_option('groups'), variables, name, strict=strict)
|
||||
self._add_host_to_keyed_groups(self.get_option('keyed_groups'), variables, name, strict=strict)
|
||||
self._set_composite_vars(self.get_option('compose'), variables, name, strict=strict)
|
||||
|
||||
def _add_vms(self, vms, hosts, pools):
|
||||
for uuid, vm in vms.items():
|
||||
group = 'with_ip'
|
||||
|
@ -213,6 +224,8 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||
self.inventory.set_variable(
|
||||
entry_name, 'os_version', vm['os_version'])
|
||||
|
||||
self._apply_constructable(entry_name, self.inventory.get_host(entry_name).get_vars())
|
||||
|
||||
def _add_hosts(self, hosts, pools):
|
||||
for host in hosts.values():
|
||||
entry_name = host['uuid']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue