Open rkbennett opened 2 years ago
Files identified in the description: None
If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
Does the module report a change that doesn't happen, or doesn't it even do that and report that everything's OK?
It shows it in the invocation, and the task completes fine, but it doesn't actually get set on the vm.
Is this some kind of "magic" or "protected" setting? I can neither see nor set it through the UI (vCenter 7.0.3d). The same with PowerCLI:
PS C:\Users\mario> $vm = Get-VM -Name "synctest"
PS C:\Users\mario> Get-AdvancedSetting -Entity $vm -Name "tools.syncTime"
PS C:\Users\mario> New-AdvancedSetting -Entity $vm -Name "tools.syncTime" -Value "TRUE" -Confirm:$false -Force:$true
Name Value Type Description
---- ----- ---- -----------
tools.syncTime TRUE VM
PS C:\Users\mario> New-AdvancedSetting -Entity $vm -Name "tools.syncTime" -Value $true -Confirm:$false -Force:$true
Name Value Type Description
---- ----- ---- -----------
tools.syncTime True VM
PS C:\Users\mario> New-AdvancedSetting -Entity $vm -Name "tools.syncTime" -Value 1 -Confirm:$false -Force:$true
Name Value Type Description
---- ----- ---- -----------
tools.syncTime 1 VM
PS C:\Users\mario> New-AdvancedSetting -Entity $vm -Name "tools.syncTime" -Value "1" -Confirm:$false -Force:$true
Name Value Type Description
---- ----- ---- -----------
tools.syncTime 1 VM
PS C:\Users\mario>
I always see a task in vCenter that completes just fine, but the time synchronization isn't changed at all. So I think this isn't really a problem of the vmware_guest
module, you just can't configure this advanced setting directly imho.
Well, reading the description of advanced_settings, IIRC it says that it can set values within the vmx file, which tools.syncTime is located in. That is why I was attempting it through that method
Well, reading the description of advanced_settings, IIRC it says that it can set values within the vmx file, which tools.syncTime is located in. That is why I was attempting it through that method
You're right, advanced_settings should be able to set an advanced setting like tools.syncTime. However, it looks like the vSphere API doesn't allow this. The module can add or change other advanced settings without any problems.
That said, I don't think this is a bug in the module. But I think it's a valid feature request to be able to enable timesync via VMware Tools somehow.
Indeed, it looks like a "magic setting". I don't know how Hashicorp Packer deals with advanced/custom settings, but it has a dedicated config param for timesync in vsphere-iso plugin.
For now, I'm managing to enable timesync using vm_shell:
---
# timesync_action: enable / disable ( default = enable )
- name: Check communication with vmware-tools
community.vmware.vmware_guest_tools_wait:
validate_certs: "{{ vsphere_validate_certs }}"
hostname: "{{ vsphere_hostname }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
datacenter: "{{ vsphere_datacenter }}"
folder: "{{ vsphere_vm_folder }}"
name: "{{ vm_name }}"
delegate_to: localhost
register: tools_wait
until: tools_wait.instance.hw_guest_id is not none
retries: 6
delay: 10
- name: Gather VM info to guess OS
delegate_to: localhost
community.vmware.vmware_guest_info:
validate_certs: "{{ vsphere_validate_certs }}"
hostname: "{{ vsphere_hostname }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
datacenter: "{{ vsphere_datacenter }}"
name: "{{ vm_name }}"
register: local_vm_info
#Assume default is SSH/*nix
- set_fact:
#vm_os: unix
vm_shell: /bin/bash
vm_shell_cwd: /tmp
vm_shell_args: '-c "/usr/bin/vmware-toolbox-cmd timesync {{ timesync_action | default("enable") }}"'
- set_fact:
#vm_os: "{{ local_vm_info.instance.hw_guest_id }}"
vm_shell: C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe
vm_shell_cwd: C:\Windows\Temp
vm_shell_args: "timesync {{ timesync_action | default('enable') }}"
when: local_vm_info.instance.hw_guest_id|lower|regex_search('^windows')
- name: Run timesync command inside the virtual machine
delegate_to: localhost
community.vmware.vmware_vm_shell:
validate_certs: "{{ vsphere_validate_certs }}"
hostname: "{{ vsphere_hostname }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
datacenter: "{{ vsphere_datacenter }}"
folder: "{{ vsphere_vm_folder }}"
vm_id: "{{ vm_name }}"
vm_username: "{{ winrm_ansible_user }}"
vm_password: "{{ winrm_ansible_password }}"
vm_shell: "{{ vm_shell }}"
vm_shell_args: "{{ vm_shell_args }}"
vm_shell_cwd: "{{ vm_shell_cwd }}"
wait_for_process: true
register: vm_shell_synctime_result
I don't think we should implement this in vmware_guest
, the module is already far too complicated.
Maybe a new module vmware_tools_config
? We could start with implementing syncTimeWithHost
and syncTimeWithHostAllowed
, but could also add other settings from ToolsConfigInfo there when the need arises.
cc @ihumster @max-carnage
SUMMARY
When attempting to set the tools.timeSync value for enabling vmware tools time synchronization changes are never actually made When using the vmware_guest module placing the configuration in advanced_settings makes no change:
I've also tried adding it under customvalue, which causes the task to fail from an unknown key
ISSUE TYPE
COMPONENT NAME
community.vmware.vmware_guest
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Kubernetes 1.20
STEPS TO REPRODUCE
EXPECTED RESULTS
vmtools timesync gets enabled
ACTUAL RESULTS
vmtools time sync remains disabled