Reputation: 1508
I need to create C:\MSI
folder to put there msi files. Here is my task:
tasks:
- name: Copy *.msi files from ./MSI to C:\MSI
file: path=C:\MSI state=directory
But I got the error:
TASK [Copy *.msi files from ./MSI to C:\MSI] ***********************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: + ~~~~~~~~~~~~~~~
fatal: [agentsmith]: FAILED! => {"changed": false, "failed": true, "msg": "The term '/usr/bin/python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."}
and in verbose mode I see that File module for some reason puts /usr/bin/python
to the Powershell script:
TASK [Copy *.msi files from ./MSI to C:\MSI] ***********************************
task path: /home/qaexpert/ansible-lab/tcagent.yml:8
<agentsmith> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO agentsmith
<agentsmith> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1477410445.62-187863101456896").FullName | Write-Host -Separator '';
<agentsmith> PUT "/tmp/tmpqOJYen" TO "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1477410445.62-187863101456896\file.ps1"
<agentsmith> EXEC Set-StrictMode -Version Latest
Try
{
/usr/bin/python 'C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1477410445.62-187863101456896\file.ps1'
}
Catch
...
Upvotes: 1
Views: 1773
Reputation: 3193
Ansible looks for /usr/bin/python
because the file
module needs Python installed on the target system. It is not possible to use normal Ansible modules for Windows target.
Look at the Ansible Windows documentation for details. On Windows hosts only modules listed in the “windows” subcategory of the Ansible module index are available.
To replace the regular file
module use the win_file
module.
Upvotes: 5