I found the problem. You have to specify the "folder" attribute, else
vmware_guest won't be able to find the VM.
On Wednesday, April 5, 2017 at 1:02:53 PM UTC-4, Diego Puertas wrote:
>
> When in state poweredoff or poweredon, vmware_guest can't find my vm,
> therefore it assumes I want to create a new VM.
>
> When in state present, it has no problem finding it.
>
>
> Consider the playbook:
>
> - name: Modify existing VM's networking, memory and CPU
>> hosts: modify
>> gather_facts: False
>> connection: local
>> vars_files:
>> - group_vars/vault/lab_credentials.yml
>> tasks:
>> - name: Power Off the VM
>> vmware_guest:
>> validate_certs: False
>> datacenter: "{{ vcenter_datacenter }}"
>> hostname: "{{ vcenter_hostname }}"
>> username: "{{ vcenter_user }}"
>> password: "{{ vcenter_passwd }}"
>> guest_id: "{{ vmware_guest_id }}"
>> name: "{{ guest_name }}"
>> state: poweredoff
>> - name: Modify the VM Specs
>> vmware_guest:
>> validate_certs: False
>> datacenter: "{{ vcenter_datacenter }}"
>> hostname: "{{ vcenter_hostname }}"
>> username: "{{ vcenter_user }}"
>> password: "{{ vcenter_passwd }}"
>> name: "{{ guest_name }}"
>> folder: "{{ guest_folder }}"
>> hardware:
>> memory_mb: "{{ guest_memory }}"
>> num_cpus: "{{ guest_cpus }}"
>> networks:
>> - name: "{{ guest_network }}"
>> device_type: "{{ guest_nic }}"
>> ip: "{{ guest_ipaddr }}"
>> netmask: "{{ guest_netmask }}"
>> gateway: "{{ guest_gateway }}"
>> customization:
>> domain: "{{ guest_domain }}"
>> dns_servers: "{{ guest_dns_servers }}"
>> dns_suffix: "{{ guest_dns_suffix }}"
>> state: present
>> - name: Turn on the VM
>> vmware_guest:
>> validate_certs: False
>> datacenter: "{{ vcenter_datacenter }}"
>> hostname: "{{ vcenter_hostname }}"
>> username: "{{ vcenter_user }}"
>> password: "{{ vcenter_passwd }}"
>> guest_id: "{{ vmware_guest_id }}"
>> name: "{{ guest_name }}"
>> state: poweredon
>
>
>
> If I power off my VM by hand, and only run the task Modify the VM Specs,
> then the task runs fine, vmware_guest has no problems finding my VM,
> using the variable "{{ guest_name }}".
>
> But if I run the tasks Power Off the VM or Turn on the VM, vmware_guest
> cannot find the VM, thus assumes I want to create a new one.
>
>
> Is this a bug, or am I doing something wrong?
>
>
> Thanks
>
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/5f2d7151-17b8-4ec1-aa82-ff9bddd09eb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.