From 56957ca45ea0202eccba9a01a7019997daa98463 Mon Sep 17 00:00:00 2001 From: Vyronas Tsingaras Date: Thu, 18 Jun 2015 21:33:16 +0300 Subject: [PATCH] Remember power state when starting vm reconfigure This commit fixes #1391 Signed-off-by: Vyronas Tsingaras --- lib/ansible/modules/cloud/vmware/vsphere_guest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/vmware/vsphere_guest.py b/lib/ansible/modules/cloud/vmware/vsphere_guest.py index 6ac8b38d645..2f385115218 100644 --- a/lib/ansible/modules/cloud/vmware/vsphere_guest.py +++ b/lib/ansible/modules/cloud/vmware/vsphere_guest.py @@ -616,6 +616,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name changes = {} request = VI.ReconfigVM_TaskRequestMsg() shutdown = False + poweron = vm.is_powered_on() memoryHotAddEnabled = bool(vm.properties.config.memoryHotAddEnabled) cpuHotAddEnabled = bool(vm.properties.config.cpuHotAddEnabled) @@ -706,7 +707,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name module.fail_json( msg="Error reconfiguring vm: %s" % task.get_error_message()) - if vm.is_powered_off(): + if vm.is_powered_off() and poweron: try: vm.power_on(sync_run=True) except Exception, e: