Windows bash and Ansible looking for /usr/bin/python on windows client

58 views
Skip to first unread message

Dan W

unread,
Jan 23, 2017, 11:07:36 AM1/23/17
to Ansible Project
So friday I updated my machine to windows 10, installed bash shell, configured kerberos and was able to perform simple actions such as win_ping, shut down a service, install a chocolatey package.
This morning came in and upgraded the bash environment in windows.
Now when running any of my playbooks that worked on friday, I am getting errors that /usr/bin/python cannot be found.
Try
{
/usr/bin/python 'C:\Users\username\AppData\Local\Temp\ansible-tmp-1485182658.36-53484537865904\setup.ps1'
}

We can see its trying to run a powershell script, but trying to run it using python.

Any ideas on why this is happening or has changed?  Where can I go to fix this locally if possible (on the ansible server)

J Hawkesworth

unread,
Jan 23, 2017, 2:30:26 PM1/23/17
to Ansible Project
So it sounds like for some reason it isn't picking up your group cars that are used to tell ansible to connect via pywinrm.

Make sure you are running from the same working directory as you were on Friday, just to be sure that the same paths apply.

Try running with -vvvvvv as well. I can't now recall if this will print out the paths it is using to determine where your inventory and group vars are, but worth a look.

That said my WSL is being strange today and not resolving hosts it has in the past, so it is possible there is something in recent windows updates that is tripping you up too.

Hope this is of some help,

Jon

Dan W

unread,
Jan 24, 2017, 9:26:07 AM1/24/17
to Ansible Project
Jon,
Don't think that's it.  Did my best to check rights and permissions, it appears that all files can be accessed and variables are being read.  See the below output (with some data removed).  You can see connecting via winrm, sending powershell script, and then attempting to run powershell script using python.

Using /etc/ansible/ansible.cfg as config file
Loading callback plugin default of type stdout, v2.0 from /usr/local/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK
: playbook.yml *********************************************************
1 plays in playbook.yml

PLAY
[windows] *****************************************************************

TASK
[setup] *******************************************************************
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/core/system/setup.py
<x.x.x.x> ESTABLISH WINRM CONNECTION FOR USER: username@domain on PORT 5986 TO x.x.x.x
<x.x.x.x> WINRM CONNECT: transport=kerberos endpoint=https://x.x.x.x:5986/wsman
<x.x.x.x> WINRM OPEN SHELL: SOME_GUID
<x.x.x.x> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1485267403.25-69902647291132").FullName | Write-Host -Separator '';
<x.x.x.x> WINRM EXEC u'PowerShell' [u'-NoProfile', u'-NonInteractive', u'-ExecutionPolicy', u'Unrestricted', u'-EncodedCommand',COMMAND_REMOVED]
<x.x.x.x> WINRM RESULT u'<Response code 0, out "C:\\Users\\shortusername", err "#< CLIXML\r\n<Objs Ver">'
<x.x.x.x> PUT "/tmp/tmpKGSDMo" TO "C:\Users\username\AppData\Local\Temp\ansible-tmp-1485267403.25-69902647291132\setup.ps1"
<x.x.x.x> WINRM PUT "/tmp/tmpKGSDMo" to "C:\Users\username\AppData\Local\Temp\ansible-tmp-1485267403.25-69902647291132\setup.ps1" (offset=95257 size=95257)
<x.x.x.x> EXEC Set-StrictMode -Version Latest
Try
{
/usr/bin/python 'C:\Users\username\AppData\Local\Temp\ansible-tmp-1485267403.25-69902647291132\setup.ps1'
}
Catch
{
$_obj
= @{ failed = $true }
If ($_.Exception.GetType)
{
$_obj
.Add('msg', $_.Exception.Message)
}
Else
{
$_obj
.Add('msg', $_.ToString())
}
If ($_.InvocationInfo.PositionMessage)
{
$_obj
.Add('exception', $_.InvocationInfo.PositionMessage)
}
ElseIf ($_.ScriptStackTrace)
{
$_obj
.Add('exception', $_.ScriptStackTrace)
}
Try
{
$_obj
.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}

J Hawkesworth

unread,
Feb 5, 2017, 3:22:39 AM2/5/17
to Ansible Project
Do you have any custom settings in your ansible.cfg?

I wonder if you are setting a particular path to python but for some reason this is getting applied to your windows hosts.

Jon

Reply all
Reply to author
Forward
0 new messages