ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
348 stars 337 forks source link

VMWare Tools connection plugin frequently bombs against Windows targets: StartProgramInGuest Error: File /bin/sh was not found #2099

Open wouterhummelink opened 4 months ago

wouterhummelink commented 4 months ago
SUMMARY
ISSUE TYPE
COMPONENT NAME

community.vmware.vmware_tools connection plugin

ANSIBLE VERSION
AAP 2.4 / Ansible 2.15 execution environment
COLLECTION VERSION
community.vmware:3.11.2
CONFIGURATION
ansible_connection: community.vmware.vmware_tools
ansible_user: Administrator
ansible_password: "sensitive"
ansible_shell_type: powershell
ansible_vmware_guest_path: /{{ deploy_windows_datacenter }}/vm/{{ deploy_windows_vm_folder }}/{{ deploy_windows_vm_name }}
ansible_vmware_validate_certs: false
OS / ENVIRONMENT

Windows 2016/2019/2022

STEPS TO REPRODUCE

We run this playbook many times per day, most succeed, but a significant percentage will bomb on a random task, or even on the wait_for_connection.

- name: Wait for connection
  ansible.builtin.wait_for_connection:
    connect_timeout: 5
    timeout: 600
    delay: 0
    sleep: 10

- name: Setup
  ansible.builtin.setup:
  register: setup
  retries: 3
  until: setup is succeeded
EXPECTED RESULTS

Jobs don't attempt to /bin/sh against windows targets

ACTUAL RESULTS
TASK [deploy_windows : Wait for connection] ************************************
task path: /runner/project/roles/deploy_windows/tasks/post_config.yml:8
wait_for_connection: attempting ping module test
wait_for_connection: attempting ping module test
wait_for_connection: attempting ping module test
Using module file /runner/requirements_collections/ansible_collections/ansible/windows/plugins/modules/win_ping.ps1
fatal: [cdmde117cf36ae3]: FAILED! => {
    "msg": "StartProgramInGuest Error: File /bin/sh was not found"
}
JCThomas4214 commented 2 months ago

I came across the same problem. I found for me it happened on new deployments of Windows OVFs. My workaround was to add a wait_for_connection task at the beginning of my playbook.

wouterhummelink commented 2 months ago

I've actually seen wait_for_connection error out the same way. I've worked around this by forcing the command to powershell.exe

Verzonden vanaf Outlook voor Androidhttps://aka.ms/AAb9ysg


From: Jason Thomas @.> Sent: Saturday, August 24, 2024 11:51:28 PM To: ansible-collections/community.vmware @.> Cc: Wouter Hummelink @.>; Author @.> Subject: Re: [ansible-collections/community.vmware] VMWare Tools connection plugin frequently bombs against Windows targets: StartProgramInGuest Error: File /bin/sh was not found (Issue #2099)

I came across the same problem. I found for me it happened on new deployments of Windows OVFs. My workaround was to add a wait_for_connectionhttps://docs.ansible.com/ansible/latest/collections/ansible/builtin/wait_for_connection_module.html task at the beginning of my playbook.

— Reply to this email directly, view it on GitHubhttps://github.com/ansible-collections/community.vmware/issues/2099#issuecomment-2308550525, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABJ3WO2YPAW65LMWTSLOHODZTD56BAVCNFSM6AAAAABJZKJOQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYGU2TANJSGU. You are receiving this because you authored the thread.Message ID: @.***>

ihumster commented 2 months ago

@wouterhummelink Could you reproduce the issue on the latest version of the collection?

wouterhummelink commented 2 months ago

I've actually changed jobs in the mean time.

Verzonden vanaf Outlook voor Androidhttps://aka.ms/AAb9ysg


From: Alexander Nikitin @.> Sent: Sunday, August 25, 2024 2:42:54 PM To: ansible-collections/community.vmware @.> Cc: Wouter Hummelink @.>; Mention @.> Subject: Re: [ansible-collections/community.vmware] VMWare Tools connection plugin frequently bombs against Windows targets: StartProgramInGuest Error: File /bin/sh was not found (Issue #2099)

@wouterhummelinkhttps://github.com/wouterhummelink Could you reproduce the issue on the latest version of the collection?

— Reply to this email directly, view it on GitHubhttps://github.com/ansible-collections/community.vmware/issues/2099#issuecomment-2308818895, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABJ3WO2H75HHNG6UXDVQ6T3ZTHGM5AVCNFSM6AAAAABJZKJOQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYHAYTQOBZGU. You are receiving this because you were mentioned.Message ID: @.***>

junaiddarajat commented 2 months ago

Facing the same issue, randomly bombs as you stated. Can you please suggest which job did you change to so I can look for alternatives meanwhile as well? This job is one of our core functionalities so we need something reliable

wouterhummelink commented 2 months ago

I meant I no longer work at the place I filed this issue for. Look for the executable setting on the VMware tools connection plugin

Op ma 26 aug 2024 13:55 schreef Junaid Darajat @.***>:

Facing the same issue, randomly bombs as you stated. Can you please suggest which job did you change to so I can look for alternatives meanwhile as well? This job is one of our core functionalities so we need something reliable

— Reply to this email directly, view it on GitHub https://github.com/ansible-collections/community.vmware/issues/2099#issuecomment-2310025177, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJ3WO7K7PPI2U4BL4PWPYDZTMJRPAVCNFSM6AAAAABJZKJOQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJQGAZDKMJXG4 . You are receiving this because you were mentioned.Message ID: @.***>

meis4h commented 3 weeks ago

@wouterhummelink Could you reproduce the issue on the latest version of the collection?

We are hitting the same issue on collection version 4.5.0 with the ansible community package 10.3.0.

We were not able to reproduce the issue reliably so far

meis4h commented 1 week ago

We were able to somewhat reliably reproduce the issue by just running enough tasks with this playbook:

- hosts: testhost
  tasks:
  - name: Run 100 connection test commands
    ansible.windows.win_ping:
    loop: "{{ range(0, 100) | list }}"

Using that we found that setting the following variable seems to be a valid workaround for the issue:

ansible_vmware_tools_executable: C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe

The four backslashes are required to work around another issue where we got the error "Unexpected failure during module execution: bad escape \\p at position 43"

wouterhummelink commented 1 week ago

That's exactly what I did, however using just powershell.exe.

Verzonden vanaf Outlook voor Androidhttps://aka.ms/AAb9ysg


From: Martin @.> Sent: Thursday, October 17, 2024 9:52:31 AM To: ansible-collections/community.vmware @.> Cc: Wouter Hummelink @.>; Mention @.> Subject: Re: [ansible-collections/community.vmware] VMWare Tools connection plugin frequently bombs against Windows targets: StartProgramInGuest Error: File /bin/sh was not found (Issue #2099)

We were able to somewhat reliably reproduce the issue by just running enough tasks with this playbook:

Using that we found that setting the following variable seems to be a valid workaround for the issue:

ansible_vmware_tools_executable: C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe

The four backslashes are required to work around another issue where we got the error "Unexpected failure during module execution: bad escape \p at position 43"

— Reply to this email directly, view it on GitHubhttps://github.com/ansible-collections/community.vmware/issues/2099#issuecomment-2418818593, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABJ3WO7FHSV4JE352XNNPN3Z35UD7AVCNFSM6AAAAABJZKJOQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJYHAYTQNJZGM. You are receiving this because you were mentioned.Message ID: @.***>

meis4h commented 1 week ago

using only powershell.exe we got StartProgramInGuest Error: File powershell.exe was not found in the same random frequency as the /bin/sh message