HI, I have Created a playbook to take a snapshot before patching of servers 
but this playbook has only one Guest_vm define so it working perfectly for 
me.

 *- name: Vmware guest snapshot create*
*   hosts: test-hypervisor*

*   tasks:*

*      - name: Create a snapshot*
*        vmware_guest_snapshot:*
*           hostname: test-hypervisior*
*           username: root*
*           password: asdfghj123**
*           datacenter: test-hypervisior*
*           folder: " /folder1/localhost.example.com/vm"*
*           name: RJRedhat01*
*           state: present*
*           validate_certs: False*
*           snapshot_name: snap55*
*           description: Test snapshot*
*        delegate_to: localhost*
*        register: snapshot_info*
*      - name: show the status*
*        debug:*
*            var: snapshot_info.snapshot_results*


#### Above Playbook is working fine for me',  But I have dozens of server 
and I want to create the snapshot of all nodes, I am using * with_item*  
for looping all nodes but it is not working for me. 


My Playbook for Multi vm_guest snapshot creation

*- name: Vmware guest snapshot create*
*   hosts: test-hypervisior*
*   tasks:*

*      - name: Create a snapshot*
*        vmware_guest_snapshot:*
*           hostname: test-hypervisior*
*           username: root*
*           password: asdfghj123**
*           datacenter: test-hypervisior*
*           folder: " /folder1/localhost.example.com/vm"*
*           name: "{{ item}}"*
*           with_items:*
*                    - RJCentos1*
*                    - RJRedhat01*
*                    - MAXFAX01*
*           state: present*
*           validate_certs: False*
*           snapshot_name: snap__with_multi_vms*
*           description: snap1_descriptioninnn*
*        delegate_to: localhost*
*        register: snapshot_info*
*      - name: show the status*
*        debug:*
*            var: snapshot_info.snapshot_results*

@@@@@@@@@@@@@@@@@@@@@@@@@@@@

 ansible-playbook vm-snap-c2.yaml -u root -k
SSH password:

PLAY [Vmware guest snapshot create] 
*************************************************************************************************************************************

TASK [Gathering Facts] 
**************************************************************************************************************************************************
Monday 20 April 2020  07:28:44 -0400 (0:00:00.056)       0:00:00.056 
**********
ok: [test-hypervisior]

TASK [Create a snapshot] 
************************************************************************************************************************************************
Monday 20 April 2020  07:28:46 -0400 (0:00:02.462)       0:00:02.519 
**********
fatal: [test-hypervisior]: FAILED! => {"msg": "The task includes an option 
with an undefined variable.* The error was: 'item' is undefined\n\nThe 
error *appears to be in '/home/akumar/vm/vm-snap-c2.yaml': line 5, column 
9, but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n\n      - name: Create a 
snapshot\n        ^ here\n"}

PLAY RECAP 
**************************************************************************************************************************************************************
test-hypervisior           : ok=1    changed=0    unreachable=0    
failed=1    skipped=0    rescued=0    ignored=0

Monday 20 April 2020  07:28:47 -0400 (0:00:00.167)       0:00:02.687 
**********
===============================================================================
Gathering Facts 
--------------------------------------------------------------------------------------------------------------------------------------------------
 
2.46s
Create a snapshot 
------------------------------------------------------------------------------------------------------------------------------------------------
 
0.17s

-- 
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/635f419e-3788-4396-bb05-9fefae07bf3e%40googlegroups.com.

Reply via email to