# vmware\_vm\_inventory filter

**URL:** <https://forum.ansible.com/t/vmware-vm-inventory-filter/33250>\
**Category:** Ansible Project\
**Created:** [June 24, 2020, 4:27pm UTC](https://forum.ansible.com/t/vmware-vm-inventory-filter/33250 "2020-06-24T16:27:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Todd\_Schaal](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@Todd\_Schaal](https://forum.ansible.com/u/Todd_Schaal)\
**Post date:** [June 24, 2020, 4:27pm UTC](https://forum.ansible.com/t/vmware-vm-inventory-filter/33250/1 "2020-06-24T16:27:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [June 24, 2020, 4:41pm UTC](https://forum.ansible.com/t/vmware-vm-inventory-filter/33250/2 "2020-06-24T16:41:47Z")

</div>

Could you please share your inventory plugin config? What you want to achieve with small example?

---

<div class="post-metadata">

**Author:** ![Todd\_Schaal](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@Todd\_Schaal](https://forum.ansible.com/u/Todd_Schaal)\
**Post date:** [June 24, 2020, 5:40pm UTC](https://forum.ansible.com/t/vmware-vm-inventory-filter/33250/3 "2020-06-24T17:40:05Z")

</div>

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
