From 93758a5141f5d9f441ff77e7ba2d1fdf7fda25d6 Mon Sep 17 00:00:00 2001 From: Robert Osowiecki Date: Wed, 17 Apr 2019 17:11:57 +0200 Subject: [PATCH] vsphere_guest: corrected fix #19716 misbehaviour (#55285) * vsphere_guest: corrected fix #19716 misbehaviour * creating machines without vm_extra_config is possible * power state operation on absent machines will fail * changelog fragment for PR #55285 (vsphere_guest bugfix) --- .../fragments/vsphere_guest-corrected-state-operations.yml | 4 ++++ lib/ansible/modules/cloud/vmware/_vsphere_guest.py | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/vsphere_guest-corrected-state-operations.yml diff --git a/changelogs/fragments/vsphere_guest-corrected-state-operations.yml b/changelogs/fragments/vsphere_guest-corrected-state-operations.yml new file mode 100644 index 00000000000..ad34cae8b6a --- /dev/null +++ b/changelogs/fragments/vsphere_guest-corrected-state-operations.yml @@ -0,0 +1,4 @@ +--- +bugfixes: + - vsphere_guest - creating machines without vm_extra_config allowed + - vsphere_guest - powering on/off absent virtual machine will fail diff --git a/lib/ansible/modules/cloud/vmware/_vsphere_guest.py b/lib/ansible/modules/cloud/vmware/_vsphere_guest.py index ff23e6daef5..614da557c55 100644 --- a/lib/ansible/modules/cloud/vmware/_vsphere_guest.py +++ b/lib/ansible/modules/cloud/vmware/_vsphere_guest.py @@ -1904,9 +1904,8 @@ def main(): module.exit_json(changed=False, msg="vm %s not present" % guest) # check if user is trying to perform state operation on a vm which doesn't exists - elif state in ['present', 'powered_off', 'powered_on'] and not all((vm_extra_config, - vm_hardware, vm_disk, vm_nic, esxi)): - module.exit_json(changed=False, msg="vm %s not present" % guest) + elif state in ['present', 'powered_off', 'powered_on'] and not all((vm_hardware, vm_disk, vm_nic, esxi)): + module.fail_json(msg="vm %s not present and not all options neccessary to create are provided" % guest) # Create the VM elif state in ['present', 'powered_off', 'powered_on']: