Closed peshay closed 2 years ago
Example: I have a name schema to name VMs, based on this with my PR it is possible to put hosts directly in specific groups, based on the inventory_hostname:
plugin: nutanix.ncp.ntnx_prism_vm_inventory
keyed_groups:
# group for customer name
- prefix: ""
separator: ''
key: "inventory_hostname | regex_replace('([a-zA-Z0-9]+)-([a-zA-Z0-9]+)-([a-zA-Z0-9]+)', '\\1')"
# group for service name
- prefix: ""
separator: ''
key: "inventory_hostname | regex_replace('([a-zA-Z0-9]+)-([a-zA-Z0-9]+)-([a-zA-Z]+)[0-9]*', '\\3')"
# group for environemnt name
- prefix: ""
separator: ''
key: "inventory_hostname | regex_replace('([a-zA-Z0-9]+)-([a-zA-Z0-9]+)-([a-zA-Z0-9]+)', '\\2')"
# group for customer environemnt name
- prefix: ""
separator: ''
key: "inventory_hostname | regex_replace('([a-zA-Z0-9]+)-([a-zA-Z0-9]+)-([a-zA-Z0-9]+)', '\\1_\\2')"
Further examples can be found here in the Ansible Documentation
FYI I just changed/overwritten my original PR. I just did a small change, because in the beginning I added additional dictionary and vm_name to the variables, but since vm_name == inventory_hostname it is not needed and therefore now more simpler PR.
Sorry, this was opened as NEW Feature, but instead I want an enhancement of the existing inventory. My apologies for the confusion, I close this one in favour of https://github.com/nutanix/nutanix.ansible/issues/235
Requirements:
Todo: