Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VMWare tools sets vm.guest.guestFamily as None for any Windows newer than Windows 7 #75

Closed
Akasurde opened this issue Mar 26, 2020 · 8 comments · Fixed by #76
Closed

Comments

@Akasurde
Copy link
Member

From @AlexDaciuk on Sep 02, 2019 17:46

SUMMARY

I'm trying to upgrade VMWare Tools on our Windows guests using vmware_guest_tools_upgrade and it fails with the error msg: Guest Operating System is other than Linux and Windows.

This just happens with guests with outdated tools because of the way the python code is written

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • vmware_vm_inventory
ANSIBLE VERSION
ansible 2.8.4
  config file = /home/alex/Source_Code/CommitIt/Playbooks/vmware-playbooks/ansible.cfg
  configured module search path = ['/home/alex/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.4 (default, Jul 16 2019, 07:12:58) [GCC 9.1.0]
CONFIGURATION
DEFAULT_HOST_LIST(/home/alex/Source_Code/CommitIt/Playbooks/vmware-playbooks/ansible.cfg) = ['/home/alex/Source_Code/CommitIt/Playbooks/vmware-playbooks/inventory/commit.vmware.yml']
DEFAULT_STDOUT_CALLBACK(/home/alex/Source_Code/CommitIt/Playbooks/vmware-playbooks/ansible.cfg) = yaml
INVENTORY_ENABLED(/home/alex/Source_Code/CommitIt/Playbooks/vmware-playbooks/ansible.cfg) = ['vmware_vm_inventory']

inventory file:

plugin: vmware_vm_inventory
strict: False
hostname: 172.30.0.11
username: administrator@vsphere.local
password: genericPassword
validate_certs: False
with_tags: True
OS / ENVIRONMENT

Ansible control node : Arch Linux with latest updates

Managed node: ESXi 6.7.0 with vCenter 6.7.0 on a IBM x3250 M4

STEPS TO REPRODUCE

Use a dynamic VMWare inventory using vmware_vm_inventory as described here

Power on a Windows guest newer than 7 and use vmware_guest_tools_upgrade to upgrade vmtools with:

vmware_guest_tools_upgrade:
    hostname: vcsa6.7.commit.local
    username: administrator@vsphere.local
    password: genericPasswrd
    datacenter: Datacenter
    validate_certs: yes
    folder: "/Datacenter/vm/"
    name: "Windows-2012-R2"
EXPECTED RESULTS

To get VMTools upgraded in case of outdated guest version or nothing in case of updated version already running

ACTUAL RESULTS

If you edit ansible/modules/cloud/vmware/vmware_guest_tools_upgrade.py in line 126, concatenating vm.guest.guestFamily to the result mesage you get None

TASK [Upgrade VMTools] ***********************************************************************************************************************************************
task path: /home/alex/Source_Code/CommitIt/Playbooks/vmware-playbooks/tasks/upgrade-vmtools.yml:25
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: alex
<127.0.0.1> EXEC /bin/sh -c 'echo ~alex && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/alex/.ansible/tmp/ansible-tmp-1567446047.572839-35641239422065 `" && echo ansible-tmp-1567446047.572839-35641239422065="` echo /home/alex/.ansible/tmp/ansible-tmp-1567446047.572839-35641239422065 `" ) && sleep 0'                                                      
Using module file /usr/lib/python3.7/site-packages/ansible/modules/cloud/vmware/vmware_guest_tools_upgrade.py
<127.0.0.1> PUT /home/alex/.ansible/tmp/ansible-local-22830mm9hnw15/tmpd4ggw0p8 TO /home/alex/.ansible/tmp/ansible-tmp-1567446047.572839-35641239422065/AnsiballZ_vmware_guest_tools_upgrade.py                                                                                                                                             
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/alex/.ansible/tmp/ansible-tmp-1567446047.572839-35641239422065/ /home/alex/.ansible/tmp/ansible-tmp-1567446047.572839-35641239422065/AnsiballZ_vmware_guest_tools_upgrade.py && sleep 0'                                                                                                       
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/alex/.ansible/tmp/ansible-tmp-1567446047.572839-35641239422065/AnsiballZ_vmware_guest_tools_upgrade.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/alex/.ansible/tmp/ansible-tmp-1567446047.572839-35641239422065/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => changed=false 
  invocation:
    module_args:
      datacenter: Datacenter
      folder: /Datacenter/vm
      hostname: vcsa6.7.commit.local
      name: Windows-2012-R2
      name_match: first
      password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      port: 443
      username: administrator@vsphere.local
      uuid: null
      validate_certs: true
  msg: Guest Operating System is other than Linux and Windows. None

Copied from original issue: ansible/ansible#61690

@Akasurde
Copy link
Member Author

From @AlexDaciuk on Jan 13, 2020 19:48

Still not working @Akasurde

ansible 2.9.2
  config file = /home/alex/Source_Code/CommitIt/Ansible/Playbooks/vmware-playbooks/ansible.cfg
  configured module search path = ['/home/alex/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.1 (default, Dec 21 2019, 20:57:38) [GCC 9.2.0]

@Akasurde Akasurde changed the title VMWare dynamic inventory plugin sets vm.guest.guestFamily as None for any Windows newer than Windows 7 VMWare tools sets vm.guest.guestFamily as None for any Windows newer than Windows 7 Mar 26, 2020
@Akasurde
Copy link
Member Author

@AlexDaciuk Thanks for reporting this. GuestFamily is not set by VMware inventory but it is set by VMware tools installed in the guest operating system.

We can add a parameter in the module called force_upgrade to override the operating system check and upgrade the VMware tools.

let me know your views on this.

Akasurde added a commit to Akasurde/community.vmware that referenced this issue Mar 26, 2020
Provide option to force upgrade VMware tools in the guest,
this useful when the VMware tools are too old and module is unable to
detect correct version of guestFamily like in the case of latest Windows.

Fixes: ansible-collections#75

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@Akasurde
Copy link
Member Author

resolved_by_pr #76

@Akasurde
Copy link
Member Author

Akasurde commented Mar 26, 2020

@AlexDaciuk, Could you please check PR #76 and let us know if it works for you? Thanks.

@AlexDaciuk
Copy link

Hello!

Sorry for the late response, I'm not working in that company anymore and I don't have access to a VMWare cluster now

But if the problem is only outdated VMWare Tools, a one time force upgrade should fix it, so it looks good to me

Cheers
Alex

@markatdxb
Copy link

markatdxb commented Apr 8, 2020

hello i just tested force_upgrade option in playbook but getting error

- name: Upgrade VMWare Tools
  vmware_guest_tools_upgrade:
    datacenter: "{{ vdi_vm_site }}"
    name: '{{ vdi_vm_name }}'
    force_upgrade: yes
    delegate_to: localhost
    register: vm_tool_upg
  ignore_errors: yes

error is - "msg": "Unsupported parameters for

in which version this has been fixed?

@Akasurde
Copy link
Member Author

Akasurde commented Apr 8, 2020

@markatdxb Could you please copy-paste the whole error message? Are you using the patched version of vmware_guest_tools_upgrade?

Thanks.

@markatdxb
Copy link

{
"msg": "Unsupported parameters for (vmware_guest_tools_upgrade) module: force_upgrade Supported parameters include: datacenter, folder, hostname, moid, name, name_match, password, port, proxy_host, proxy_port, username, uuid, validate_certs",
"invocation": {
"module_args": {
"datacenter": "DC",
"name": "TEST",
"force_upgrade": true,
"hostname": "hostname",
"username": "test",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"validate_certs": "False"
}
},
"_ansible_no_log": false,
"changed": false,
"_ansible_delegated_vars": {
"ansible_host": "localhost"
}
}

Please advice in which collection version was this fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants