hosts: localhost
  gather_facts: false
  tasks:
  - vmware_guest_info:
      hostname:  "{{ vcenter_hostname }}"
      username: eu\wavesservice
      password: GHb!DW|79Z5i
      validate_certs: no
      datacenter: Test
      name: "{{ VM_Name }}"
      schema: "vsphere"
      properties: ["runtime.powerState"]
    delegate_to: localhost
    register: vminfo

  - debug:
      var: vminfo

  - vmware_guest_powerstate:
      validate_certs: no
      hostname: "{{ vcenter_hostname }}"
      username: eu\wavesservice
      password: GHb!DW|79Z5i
      name: "{{ VM_Name }}"
      state: powered-off
    delegate_to: localhost
    when: vminfo != "poweredOff"


  - name: Deleting The Virutal Machine
    vmware_guest:
      hostname:  "{{ vcenter_hostname }}"
      username: eu\wavesservice
      password: GHb!DW|79Z5i
      validate_certs: no
      cluster: "{{ cluster_name }}"
      name: "{{ VM_Name }}"
      state: absent
    delegate_to: localhost
    register: facts


---
- name: get info vm
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
  - name: get info about the virtual machine
    vmware_guest_info:
      hostname: vcnerter
      username: 
      password: xxxxxxxx
      datacenter: DC
      validate_certs: False
      name: myvm
      schema: "vsphere"
      properties: ["config.hardware.memoryMB", "guest.disk", "overallStatus"
]
    delegate_to: localhost
    register: info
  

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/05188019-3473-41eb-ba7a-1984ab313e81%40googlegroups.com.

Reply via email to