mirror of https://github.com/ansible/ansible.git
VMware: Provide verbose message about non-existent VM (#35682)
This fix adds a verbose message about non-existent VM when specified with operation, due to idempotency we can not detect correct state. Fixes: #27384 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>pull/35700/head
parent
4094ba7682
commit
367258507a
@ -0,0 +1,57 @@
|
||||
# Test code for the vmware_guest module.
|
||||
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 5000
|
||||
state: started
|
||||
|
||||
- name: kill vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/killall
|
||||
- name: start vcsim with no folders
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
|
||||
register: vcsim_instance
|
||||
|
||||
- name: Wait for Flask controller to come up online
|
||||
wait_for:
|
||||
host: "{{ vcsim }}"
|
||||
port: 443
|
||||
state: started
|
||||
|
||||
- name: get a list of VMS from vcsim
|
||||
uri:
|
||||
url: http://{{ vcsim }}:5000/govc_find?filter=VM
|
||||
register: vmlist
|
||||
|
||||
- debug: var=vcsim_instance
|
||||
- debug: var=vmlist
|
||||
|
||||
- name: get a guest
|
||||
set_fact:
|
||||
guest1: "{{ vmlist.json[0] }}"
|
||||
|
||||
- name: Perform operation on non-existent VM
|
||||
vmware_guest:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
name: "non_existent_vm"
|
||||
datacenter: "{{ (guest1|basename).split('_')[0] }}"
|
||||
folder: "{{ guest1 | dirname }}"
|
||||
state: poweredoff
|
||||
register: non_existent_vm_ops
|
||||
ignore_errors: yes
|
||||
|
||||
- debug: var=non_existent_vm_ops
|
||||
|
||||
- name: assert that changes were not made
|
||||
assert:
|
||||
that:
|
||||
- not non_existent_vm_ops.changed
|
||||
- non_existent_vm_ops.msg is defined
|
||||
- "'Unable to find the datastore with given parameters' in non_existent_vm_ops.msg"
|
Loading…
Reference in New Issue