Control node:
Remote node:
I have a powershell script (warning.ps1) on my remote node that runs fine when I double click on it. I also have a copy of the powershell script in my control node playbook directory. As I understand, the following play ought to run the powershell script
---
- name: test warning
hosts: windows
tasks:
- name: warning
script: warning.ps1
Here's what I get when I run the playbook...
[ansmgr@dhcp1-60-20 playbooks]$ ansible-playbook warning_powershell.yml -vvvv
No config file found; using defaults
Loaded callback default of type stdout, v2.0
PLAYBOOK: warning_powershell.yml ***********************************************
1 plays in warning_powershell.yml
PLAY [test warning] ************************************************************
TASK [warning] *****************************************************************
task path: /etc/ansible/playbooks/warning_powershell.yml:6
<ADS-6999> ESTABLISH WINRM CONNECTION FOR USER: ansibleAdmin on PORT 5985 TO ADS-6999
<ADS-6999> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1463494972.72-265383630304564").FullName | Write-Host -Separator '';
<ADS-6999> PUT "/etc/ansible/playbooks/warning.ps1" TO "C:\Users\ansibleAdmin\AppData\Local\Temp\ansible-tmp-1463494972.72-265383630304564\warning.ps1"
<ADS-6999> EXEC & 'C:\Users\ansibleAdmin\AppData\Local\Temp\ansible-tmp-1463494972.72-265383630304564\warning.ps1'
<ADS-6999> EXEC Set-StrictMode -Version Latest
Remove-Item "C:\Users\ansibleAdmin\AppData\Local\Temp\ansible-tmp-1463494972.72-265383630304564" -Force -Recurse;
changed: [ADS-6999] => {"changed": true, "invocation": {"module_args": {"_raw_params": "warning.ps1"}, "module_name": "script"}, "rc": 0, "stderr": "", "stdout": "", "stdout_lines": []}
PLAY RECAP *********************************************************************
ADS-6999 : ok=1 changed=1 unreachable=0 failed=0
It seems like the script is getting copied to a temporary directory but is not executing. I have also tried using raw: but that doesn't work either and I'd prefer to use script: