0

I'm fairly new to Ansible and VMware. I've created a playbook to gather inventory info about all the VM's in a Vcenter instance and it works fine, but I want the inventory output to include more than just the VM names. This is the playbook I have below.

---
plugin: community.vmware.vmware_vm_inventory
strict: False
hostname: 192.168.1.1
username: fake
password: name
validate_certs: False
with_tags: False
hostnames:
- config.name
properties:
- config.name
- config.guestId
- guest.ipAddress
- summary.runtime.powerState

This is a partial output of a long list:

 |--@centos64Guest:
  |  |--A-CentOS-xx.xx.xx.xx
  |  |--A.s-CentOS-xx.xx.xx.xx
  |  |--Alpha-DNS-xx.xx(CentOS)
  |  |--Alt-Services-xx.xx.xx.x
  |  |--Alt-Services-xx.xx.xx.xx
  |  |--Alt-Services-xx
  |  |--Alt-Services-xx.xxx
  |  |--Alt-Services-xx.xx

I only get the name of the VM. Is there a way to include more information about each VM like uptime/downtime? I know I can use a filter to just include powered off VM's...

- summary.runtime.powerState == "poweredOff"

But ultimately I need to know how long each VM has been powered off.

Thanks

  • Should be interesting - that information isn't tracked as far as I know even in vcenter. You would have to scrape the logs (if they go back that far) to find the poweroff event. – Semicolon Nov 29 '22 at 04:16

0 Answers0