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

community.vmware.vmware_vm_inventory creates groups for each folder in the hosts path #1688

Open
devidebyzero opened this issue Mar 22, 2023 · 3 comments · May be fixed by #2248
Open

community.vmware.vmware_vm_inventory creates groups for each folder in the hosts path #1688

devidebyzero opened this issue Mar 22, 2023 · 3 comments · May be fixed by #2248

Comments

@devidebyzero
Copy link

devidebyzero commented Mar 22, 2023

SUMMARY

vCenter folders:
MyDC
Folder1
Folder2
Folder3
MyVM

Source variables in Inventory:

plugin: community.vmware.vmware_vm_inventory
hostnames:
  - config.name
properties:
  - availableField
  - configIssue
  - configStatus
  - customValue
  - datastore
  - effectiveRole
  - guestHeartbeatStatus
  - layout
  - layoutEx
  - parent
  - name
  - network
  - overallStatus
  - parentVApp
  - permission
  - recentTask
  - resourcePool
  - rootSnapshot
  - snapshot
  - triggeredAlarmState
  - value
  - capability
  - config
  - guest
  - runtime
  - storage
  - summary
resources:
  - folder:
    - Folder1
    resources:
      - folder:
        - Folder2
      resources:
        - folder:
          - Folder3
compose:
  ansible_host: guest.ipAddress
  datacenter_name: path|regex_replace('^Datacenters\/', '')|regex_replace('\/vm.*$','')
with_nested_properties: true
with_tags: true
with_path: true

I end up with the following groups -
Datacenters
Datacenters_MyDC
Datacenters_MyDC_vm
Datacenters_MyDC_vm_Folder1
Datacenters_MyDC_vm_Folder1_Folder2
Datacenters_MyDC_vm_Folder1_Folder2_Folder3

If I add:

keyed_groups:
  - key: path|regex_replace('^Datacenters\/.*\/vm\/', '')|regex_replace('\/.*$','')
    prefix: 'folder'
    separator: '__'

I get my group 'folder__Folder3' along the ones above

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.vmware.vmware_vm_inventory

ANSIBLE VERSION
2.12.5.post0
COLLECTION VERSION
AWX 21.10.2
CONFIGURATION
AWX 21.10.2
OS / ENVIRONMENT
STEPS TO REPRODUCE
plugin: community.vmware.vmware_vm_inventory
hostnames:
  - config.name
properties:
  - availableField
  - configIssue
  - configStatus
  - customValue
  - datastore
  - effectiveRole
  - guestHeartbeatStatus
  - layout
  - layoutEx
  - parent
  - name
  - network
  - overallStatus
  - parentVApp
  - permission
  - recentTask
  - resourcePool
  - rootSnapshot
  - snapshot
  - triggeredAlarmState
  - value
  - capability
  - config
  - guest
  - runtime
  - storage
  - summary
resources:
  - folder:
    - Folder1
    resources:
      - folder:
        - Folder2
      resources:
        - folder:
          - Folder3
compose:
  ansible_host: guest.ipAddress
  datacenter_name: path|regex_replace('^Datacenters\/', '')|regex_replace('\/vm.*$','')
with_nested_properties: true
with_tags: true
with_path: true
EXPECTED RESULTS

Only the group I configure:
group 'folder__Folder3'

I don't want the groups like -

Datacenters
Datacenters_MyDC
Datacenters_MyDC_vm
Datacenters_MyDC_vm_Folder1
Datacenters_MyDC_vm_Folder1_Folder2
Datacenters_MyDC_vm_Folder1_Folder2_Folder3

To be created automatically.
Need an ooption to disable this behaviour.

ACTUAL RESULTS

Inventory groups:

Datacenters
Datacenters_MyDC
Datacenters_MyDC_vm
Datacenters_MyDC_vm_Folder1
Datacenters_MyDC_vm_Folder1_Folder2
Datacenters_MyDC_vm_Folder1_Folder2_Folder3
folder__Folder3


@magic88305
Copy link

same question

@YourSandwich
Copy link

me to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants