I have the vmware_vm_inventory plugin working. My issue is that it returns everything, including powered-off vms. I can filter them out when I run my playbooks, but I’d prefer they not be in my inventory in the first place. Is there an easy way to accomplish this?
Could you please share your inventory plugin config? What you want to achieve with small example?
here is my config
plugin: vmware_vm_inventory
strict: False
hostname: {{ vcenter_host }}.{{ domain_name }}
username: {{ vcenter_user }}
password: {{ vcenter_password }}
validate_certs: False
with_tags: True
ansible_python_interpreter: /tmp/vminv_virtualenv/bin/python
I run
python $(which ansible-inventory) --list -i ./{{ vcenter_host }}.{{ inventory_yaml }} --vault-password-file={{ password_file }} -y > …/{{ inventory_directory }}/hosts.{{ vcenter_host }}.ymlansible-inventory -i <config.yml> -y
here is what I get:
all:
children:
Application: {}
CFG: {}
DEMO: {}
DEV:
hosts:
*********:
ansible_host: *********
config.cpuHotAddEnabled: false
config.cpuHotRemoveEnabled: false
config.hardware.numCPU: 4
config.instanceUuid: 5026aa79-6b5e-8310-46be-850498deb8a4
config.name: *********
config.template: false
guest.guestId: windows8Server64Guest
guest.guestState: running
guest.hostName: *********
guest.ipAddress: *********
name: *********
runtime.maxMemoryUsage: 16384
*********:
ansible_host: *********
config.cpuHotAddEnabled: false
config.cpuHotRemoveEnabled: false
config.hardware.numCPU: 4
config.instanceUuid: 50265e22-8599-48cf-c6ed-3f060416f733
config.name: *********
config.template: false
guest.guestId: windows8Server64Guest
guest.guestState: running
guest.hostName: *********
guest.ipAddress: *********
name: *********
runtime.maxMemoryUsage: 16384
…
poweredOff:
hosts:
20100608p_ws2k8ex64sp2:
config.cpuHotAddEnabled: false
config.cpuHotRemoveEnabled: false
config.hardware.numCPU: 1
config.instanceUuid: 5014d83b-9acb-1c2a-b830-1e78080ce71c
config.name: 20100608p_WS2K8Ex64SP2
config.template: false
guest.guestId: null
guest.guestState: notRunning
guest.hostName: null
guest.ipAddress: null
name: 20100608p_WS2K8Ex64SP2
runtime.maxMemoryUsage: null
20150928-w2k12r2:
config.cpuHotAddEnabled: true
config.cpuHotRemoveEnabled: false
config.hardware.numCPU: 2
config.instanceUuid: 5288e531-2433-c90a-f922-d5b956ebb018
config.name: 20150928-w2k12r2
config.template: false
guest.guestId: null
guest.guestState: notRunning
guest.hostName: WIN-PJKUVJ4HV62
guest.ipAddress: null
name: 20150928-w2k12r2
runtime.maxMemoryUsage: null