cloudstack: cs_instance: fix userdata not up to date (#18942)

Fixes unnecessary VM restart.

VM userdata is currently not returned by the API listVirtualMachine and task will always be marked as changed in has_changed(), which will result in an unnecessary VM restart if force=true.

Reported by @Mayeu
pull/19037/head
René Moser 8 years ago committed by GitHub
parent 1da20c9716
commit 345e39e1b1

@ -533,6 +533,10 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
if not vpc_id and self.is_vm_in_vpc(vm=v): if not vpc_id and self.is_vm_in_vpc(vm=v):
continue continue
if instance_name.lower() in [ v['name'].lower(), v['displayname'].lower(), v['id'] ]: if instance_name.lower() in [ v['name'].lower(), v['displayname'].lower(), v['id'] ]:
# Query the user data if we need to
if 'userdata' not in v and self.get_user_data() is not None:
res = self.cs.getVirtualMachineUserData(virtualmachineid=v['id'])
v['userdata'] = res['virtualmachineuserdata'].get('userdata',"")
self.instance = v self.instance = v
break break
return self.instance return self.instance

Loading…
Cancel
Save