Thank you, Abhijeet. That worked!!

On Thursday, 7 May 2020 14:16:53 UTC+5:30, Abhijeet Kasurde wrote:
>
> You can use filters - 
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html
>
> Either - "{{ hostname | to_uuid }}" or  "{{ '%Y_%m_%d_%H_%M_%S' | strftime 
> }}"
>
> On Thu, May 7, 2020 at 2:00 PM Mani <[email protected] <javascript:>> 
> wrote:
>
>> I am a newbie to ansible and I am trying to take a snapshot of multiple 
>> VM's with a random snapshot name including the VM name (vmname + random 
>> number or timestamp). 
>>
>> I am able to take snapshot using the VM name with the below code:
>>
>> ---
>> - name: Gather all registered virtual machines
>>   vmware_vm_info:
>>     hostname: '{{ running_host }}'
>>     username: '{{ esxi_user }}'
>>     password: '{{ esxi_pass }}'
>>   delegate_to: localhost
>>   register: vminfo
>>
>> - name: Create a snapshot
>>   vmware_guest_snapshot:
>>     hostname: "{{ vcenter_server }}"
>>     username: "{{ vcenter_user }}"
>>     password: "{{ vcenter_pass }}"
>>     datacenter: 'VDC'
>>     folder: 'VDC/vm/'
>>     name: "{{ item.guest_name }}"
>>     state: present
>>     snapshot_name: "{{ item.guest_name }}"
>>   with_items:
>>     - "{{ vminfo.virtual_machines }}"
>>
>> Please provide your inputs.
>>
>> -- 
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/8c90bfb1-30ff-4f56-b1db-42320a9e55c8%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/8c90bfb1-30ff-4f56-b1db-42320a9e55c8%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Thanks,
> Abhijeet Kasurde
>

-- 
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/f8fab4c3-daee-4121-af73-10f02d28f363%40googlegroups.com.

Reply via email to