Skip to content

Commit

Permalink
Add a flag 'force_upgrade' in vmware_guest_tools_upgrade (ansible-col…
Browse files Browse the repository at this point in the history
…lections#76)

Add a flag 'force_upgrade' in vmware_guest_tools_upgrade

Reviewed-by: https://github.com/apps/ansible-zuul
  • Loading branch information
Akasurde authored and Michal Novacek committed Jun 5, 2020
1 parent e9873be commit 6ba728e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/75-vmware_guest_tool_upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Add a flag 'force_upgrade' to force VMware tools upgrade installation (https://github.com/ansible-collections/vmware/issues/75).
14 changes: 13 additions & 1 deletion plugins/modules/vmware_guest_tools_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@
- Destination datacenter where the virtual machine exists.
required: True
type: str
force_upgrade:
description:
- This flag overrides the guest operating system detection and forcibly upgrade
VMware tools or open-vm-tools.
- This is useful when VMware tools is too old and unable to detect the 'guestFamily' value.
- Using this flag may sometime give unexpected results since module will override the default
behaviour of 'guestFamily' detection.
default: False
type: bool
required: False
extends_documentation_fragment:
- community.vmware.vmware.documentation
Expand Down Expand Up @@ -148,7 +158,8 @@ def upgrade_tools(self, vm):
# Upgrade tools on Linux and Windows guests
elif vm.guest.toolsStatus == "toolsOld":
try:
if vm.guest.guestFamily in ["linuxGuest", "windowsGuest"]:
force = self.module.params.get('force_upgrade')
if force or vm.guest.guestFamily in ["linuxGuest", "windowsGuest"]:
task = vm.UpgradeTools()
changed, err_msg = wait_for_task(task)
result.update(changed=changed, msg=to_native(err_msg))
Expand Down Expand Up @@ -178,6 +189,7 @@ def main():
moid=dict(type='str'),
folder=dict(type='str'),
datacenter=dict(type='str', required=True),
force_upgrade=dict(type='bool', default=False),
)
module = AnsibleModule(
argument_spec=argument_spec,
Expand Down

0 comments on commit 6ba728e

Please sign in to comment.