Comments (12)
Potentially but let's leave this one open for now and you can just reference it. I still want to try and play around with it a bit more to figure out if that's really the case.
from ansible.windows.
When running a simple reboot all task with win_reboot, same results: (Also on Windows 10)
Playbook:
---
- name: Reboot Windows machines
hosts: all
gather_facts: yes
tasks:
- name: Reboot the machine with all defaults
when: ansible_facts['os_family'] == "Windows"
win_reboot:
Result:
{
"reboot": false,
"msg": "win_reboot: failed to get host boot time info, rc: 1, stdout: , stderr: ",
"_ansible_no_log": false,
"changed": false
}
Running it on a basic CentOS 8 host with Ansbile V2.9.5:
ansible-playbook -i inventory_chocoladebol base_reboot.yml -vvvvv
ansible-playbook 2.9.5
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /root/base_vm/inventory_chocoladebol as it did not pass its verify_file() method
script declined parsing /root/base_vm/inventory_chocoladebol as it did not pass its verify_file() method
auto declined parsing /root/base_vm/inventory_chocoladebol as it did not pass its verify_file() method
Parsed /root/base_vm/inventory_chocoladebol inventory source with yaml plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3.6/site-packages/ansible/plugins/callback/default.py
PLAYBOOK: base_reboot.yml ********************************************************************************************************************************************************************************************************************************************************************
Positional arguments: base_reboot.yml
verbosity: 5
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/root/base_vm/inventory_chocoladebol',)
forks: 5
1 plays in base_reboot.yml
PLAY [Reboot Windows machines] ***************************************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************************************************************
task path: /root/base_vm/base_reboot.yml:2
Using module file /usr/lib/python3.6/site-packages/ansible/modules/windows/setup.ps1
ok: [dc-01]
META: ran handlers
TASK [Reboot the machine with all defaults] **************************************************************************************************************************************************************************************************************************************************
task path: /root/base_vm/base_reboot.yml:6
fatal: [dc-01]: FAILED! => {
"changed": false,
"msg": "win_reboot: failed to get host boot time info, rc: 1, stdout: , stderr: ",
"reboot": false
}
PLAY RECAP ***********************************************************************************************************************************************************************************************************************************************************************************
dc-01 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
from ansible.windows.
This does not seem to be a module issue but a ansible_connection issue. As I am using the same module win_reboot and win_domain both using WinRM in a new test setup they work without issues. When using ansible_connection: psrp with a socks5h proxy in the middle both modules work without issue.
Is this a bug report for the connection plugin vmware_tools?
from ansible.windows.
It sounds like a problem with vmware_tools and how we send the command to be executed. Does it work on this host just through the he winrm connection plugin.
from ansible.windows.
It sounds like a problem with vmware_tools and how we send the command to be executed. Does it work on this host just through the he winrm connection plugin.
It does, the win_domain module does also have an issue when using the vmware_tools plugin. While with WinRM plugin and PSRP plugin they work without any issue.
from ansible.windows.
Ok, this is going to be hard for me to test as I don't have a VMWare host for me to test against. My guess is that because we are running a direct PowerShell cmd https://github.com/ansible-collections/ansible.windows/blob/master/plugins/action/win_reboot.py#L29 against the host for the reboot check it is failing because the shell on the VMWare tools connection plugin is cmd. It's the same for winrm but the actual connection plugin there encodes the script in a powershell command itself so it's not a problem there.
from ansible.windows.
Ok, this is going to be hard for me to test as I don't have a VMWare host for me to test against. My guess is that because we are running a direct PowerShell cmd https://github.com/ansible-collections/ansible.windows/blob/master/plugins/action/win_reboot.py#L29 against the host for the reboot check it is failing because the shell on the VMWare tools connection plugin is cmd. It's the same for winrm but the actual connection plugin there encodes the script in a powershell command itself so it's not a problem there.
Weird because when using VMware Tools as connection plugin, I also let it know that I use Powershell. Example:
fs-01:
vm_template: Windows2019-Template
deploy_vsphere_datastore: datastore-01
guest_custom_ip: 172.27.72.72
ansible_connection: vmware_tools
ansible_shell_type: powershell
What can we do to fix or troubleshoot this?
from ansible.windows.
You tell it to use Ansible's powershell shell plugin but in reality if you were to open a new shell with the VMWare tool it will be in the context of cmd so if you were to run a command it needs to be valid in cmd. The same is also true to the winrm connection plugin but it just makes sure that any commands it executes is wrapped in a powershell command so the default shell of the actual API does not matter.
Ultimately if I am correct here the fix is 1 of 2 choices
- Change the vmware_tools connection plugin to act the same as winrm and make sure each Windows script that is run is encoded as a powershell command
- Fix up win_reboot to just always call the command with powershell.exe
The 2nd is definitely easier to do but I'm not sure if that's the right way to go. It opens up the possibility of connection plugins expecting things to always be a valid cmd command when that's not how things are today.
from ansible.windows.
You tell it to use Ansible's powershell shell plugin but in reality if you were to open a new shell with the VMWare tool it will be in the context of cmd so if you were to run a command it needs to be valid in cmd. The same is also true to the winrm connection plugin but it just makes sure that any commands it executes is wrapped in a powershell command so the default shell of the actual API does not matter.
Ultimately if I am correct here the fix is 1 of 2 choices
- Change the vmware_tools connection plugin to act the same as winrm and make sure each Windows script that is run is encoded as a powershell command
- Fix up win_reboot to just always call the command with powershell.exe
The 2nd is definitely easier to do but I'm not sure if that's the right way to go. It opens up the possibility of connection plugins expecting things to always be a valid cmd command when that's not how things are today.
I Agree, option 2 seems easy but not the way to go. I think this makes the only option to open up a request over at the vmware_tools plugin repo?
from ansible.windows.
Still happening when connection type is NTLM:
from ansible.windows.
from ansible.windows.
@gdlkk Check your Powershell permissions. I had to do that over a year ago. Try looking for the default permissions in a Windows installation and check for your ping / rw permissions.
I went through hell to figure that out 😅, not easy to traceback, try asking on an IRC channel or a LUG, or try asking on a more specific place, not the no-one-knows-anything places 🙃
from ansible.windows.
Related Issues (20)
- win_environment : Maybe add an option to read variable content ? HOT 6
- Error during machine sid retrieval: An error (1788) occurred while enumerating the group membership. The member's SID could not be resolved. HOT 8
- Access denied after renaming windows host : Server not found in Kerberos database HOT 10
- Failed to create temporary directory when running win_template module against Windows Server 2019 HOT 10
- win_copy doesnt work when folder name has special character HOT 3
- Add account_expires functionality from the Set-LocalUser PowerShell Cmdlet HOT 2
- Using Machine credentials from AAP passed to playbook with ansible.windows.win_copy fails HOT 3
- ERROR DURING WINRM SEND INPUT - attempting to recover: WinRMTransportError Bad HTTP response returned from server. Code 413 HOT 2
- win_copy module not handling an invalid path correctly. HOT 2
- Feature request: A better win_acl module HOT 1
- Error in Windows Update: Unhandled exception while executing module: Cannot process request because the process (PID) has exited HOT 4
- Docs for setup reference ansible.builtin instead of ansible.windows
- Instances of ansible.builtin instead of ansible.windows in docs for overloaded module names
- Galaxy Download does not work HOT 1
- win_powershell sensitive parameters using `::new()` HOT 1
- ansible.windows.win_owner module fails to run recursively if ansible_user does not have access to the child items HOT 2
- Not able to run the win_update task on Windows server when Trellix Threat prevention enabled with Ansible version 2.16.6 HOT 11
- Unable to Install 'VirtualMachinePlatform' Feature on Windows Server 2022 using win_feature Module HOT 1
- win_updates: not find cumulative updates but appears on GUI HOT 4
- Error in win_stat when fetching a file with brackets [] in the name HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible.windows.