Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmware_vm_inventory: support fetching tag category #350

Closed
harrymitchinson opened this issue Aug 17, 2020 · 3 comments · Fixed by #425
Closed

vmware_vm_inventory: support fetching tag category #350

harrymitchinson opened this issue Aug 17, 2020 · 3 comments · Fixed by #425
Labels
affects_2.10 cloud feature This issue/PR relates to a feature request inventory inventory plugin needs_triage Needs a first human triage before being processed. plugins plugin (any type)

Comments

@harrymitchinson
Copy link

harrymitchinson commented Aug 17, 2020

SUMMARY

In vmware_vm_inventory we can fetch tags from Virtual Machines however we cannot fetch the categories which these tags belong to, this leads to tags with missing context as to what they actually belong to and how they should be grouped.

The tags returned by the inventory plugin are in the form of an array like:

{ 
  "tags": [ "prd", "loadbalancer", "vsphere", "ansible", "pci", "pulumi" ]
}

This would be more useful if the tags were a dictionary/map, using the tag category as the key like:

{ 
  "tags": {
      "environment": "prd",
      "network": "pci",
      "service": "loadbalancer",
      // etc..
   }
}
ISSUE TYPE
  • Feature Idea
COMPONENT NAME

vmware_vm_inventory

ADDITIONAL INFORMATION
plugin: "community.vmware.vmware_vm_inventory"
strict: false
hostname: vcenter.local
validate_certs: false
with_tags: true
keyed_groups:
  - key: tags
    prefix: "vmware_tag_"
    separator: ""
hostnames:
  - config.name
groups:
  vmware: true
filters:
  - "'ansible' in tags"
  - "'prd' in tags"
  - runtime.powerState == "poweredOn"

The above could become:

plugin: "community.vmware.vmware_vm_inventory"
strict: false
hostname: vcenter.local
validate_certs: false
with_tags: true
keyed_groups:
  - key: tags
    prefix: "vmware_tag_"
    separator: ""
  - key: tags.project
    prefix: "vmware_tag_project_"
    separator: ""
  - key: tags.service
    prefix: "vmware_tag_service_"
    separator: ""
  - key: tags.network
    prefix: "vmware_tag_network_"
    separator: ""
hostnames:
  - config.name
groups:
  vmware: true
filters:
  - tags.manager == "ansible"
  - tags.environment == "prd"
  - runtime.powerState == "poweredOn"

This would then allow us to create groups with more context such as vmware_tag_service_nginx or vmware_tag_network_pci etc.

@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added affects_2.10 feature This issue/PR relates to a feature request inventory inventory plugin needs_triage Needs a first human triage before being processed. labels Aug 19, 2020
@ansibullbot ansibullbot added cloud plugins plugin (any type) labels Aug 28, 2020
@Akasurde
Copy link
Member

@harrymitchinson Thanks for suggesting this feature.

I would like to discuss this before implementing the following things -

  1. We have to support the existing tags fact for backward compatability, so we need to add a new key for new fact gathered with category. What is good key name? I am thinking about categories, tag_category, advance_tag and tag_categories etc.
  2. What happens when we have same category name ? like two different tags with same category.

Screenshot 2020-09-30 at 14 58 44

Let me know your views.

Akasurde added a commit to Akasurde/community.vmware that referenced this issue Oct 7, 2020
Now, vmware_vm_category can retrive categories and
related to tags.

Fixes: ansible-collections#350

Signed-off-by: Abhijeet Kasurde <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.10 cloud feature This issue/PR relates to a feature request inventory inventory plugin needs_triage Needs a first human triage before being processed. plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants