Hi there, somewhat new to Ansible, just using it for the past year on Linux hosts. I’m working on a project that has me applying ansible to a windows deployment scenario and I find myself in need of the template capability to push customized configuration files to my windows hosts. Is there some way to achieve this right now in the devel branch? On a lark I tried this in my script and was rewarded with the following output:
TASK: [xxx/yyyyyy | Personalize the wptdriver.ini file for the instance] ***
<192.168.56.102> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO 192.168.56.102
<192.168.56.102> WINRM REUSE EXISTING CONNECTION: vagrant:63623900c8bbf21c706c45dcb7a2c083@192.168.56.102:5986
<192.168.56.102> EXEC (New-Item -Type Directory -Path $env:temp -Name “ansible-tmp-1410996840.36-253897514095560”).FullName | Write-Host -Separator ‘’;
<192.168.56.102> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-EncodedCommand’, ‘KABOAGUAdwAtAEkAdABlAG0AIAAtAFQAeQBwAGUAIABEAGkAcgBlAGMAdABvAHIAeQAgAC0AUABhAHQAaAAgACQAZQBuAHYAOgB0AGUAbQBwACAALQBOAGEAbQBlACAAIgBhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADQAMQAwADkAOQA2ADgANAAwAC4AMwA2AC0AMgA1ADMAOAA5ADcANQAxADQAMAA5ADUANQA2ADAAIgApAC4ARgB1AGwAbABOAGEAbQBlACAAfAAgAFcAcgBpAHQAZQAtAEgAbwBzAHQAIAAtAFMAZQBwAGEAcgBhAHQAbwByACAAJwAnADsA’]
<192.168.56.102> WINRM RESULT <Response code 0, out “C:\Users\vagrant\App”, err “”>
<192.168.56.102> EXEC If (Test-Path -PathType Leaf “C:\webpagetest\wptdriver.ini”) { $sp = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider; $fp = [System.IO.File]::Open(“C:\webpagetest\wptdriver.ini”, [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read); [System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace(“-”, “”).ToLower(); $fp.Dispose(); } ElseIf (Test-Path -PathType Container “C:\webpagetest\wptdriver.ini”) { Write-Host “3”; } Else { Write-Host “1”; }
<192.168.56.102> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-EncodedCommand’, ‘SQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAC0AUABhAHQAaABUAHkAcABlACAATABlAGEAZgAgACIAQwA6AFwAdwBlAGIAcABhAGcAZQB0AGUAcwB0AFwAdwBwAHQAZAByAGkAdgBlAHIALgBpAG4AaQAiACkACgB7AAoAJABzAHAAIAA9ACAAbgBlAHcALQBvAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBTAGUAYwB1AHIAaQB0AHkALgBDAHIAeQBwAHQAbwBnAHIAYQBwAGgAeQAuAE0ARAA1AEMAcgB5AHAAdABvAFMAZQByAHYAaQBjAGUAUAByAG8AdgBpAGQAZQByADsACgAkAGYAcAAgAD0AIABbAFMAeQBzAHQAZQBtAC4ASQBPAC4ARgBpAGwAZQBdADoAOgBPAHAAZQBuACgAIgBDADoAXAB3AGUAYgBwAGEAZwBlAHQAZQBzAHQAXAB3AHAAdABkAHIAaQB2AGUAcgAuAGkAbgBpACIALAAgAFsAUwB5AHMAdABlAG0ALgBJAE8ALgBGAGkAbABlAG0AbwBkAGUAXQA6ADoATwBwAGUAbgAsACAAWwBTAHkAcwB0AGUAbQAuAEkATwAuAEYAaQBsAGUAQQBjAGMAZQBzAHMAXQA6ADoAUgBlAGEAZAApADsACgBbAFMAeQBzAHQAZQBtAC4AQgBpAHQAQwBvAG4AdgBlAHIAdABlAHIAXQA6ADoAVABvAFMAdAByAGkAbgBnACgAJABzAHAALgBDAG8AbQBwAHUAdABlAEgAYQBzAGgAKAAkAGYAcAApACkALgBSAGUAcABsAGEAYwBlACgAIgAtACIALAAgACIAIgApAC4AVABvAEwAbwB3AGUAcgAoACkAOwAKACQAZgBwAC4ARABpAHMAcABvAHMAZQAoACkAOwAKAH0ACgBFAGwAcwBlAEkAZgAgACgAVABlAHMAdAAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAVAB5AHAAZQAgAEMAbwBuAHQAYQBpAG4AZQByACAAIgBDADoAXAB3AGUAYgBwAGEAZwBlAHQAZQBzAHQAXAB3AHAAdABkAHIAaQB2AGUAcgAuAGkAbgBpACIAKQAKAHsACgBXAHIAaQB0AGUALQBIAG8AcwB0ACAAIgAzACIAOwAKAH0ACgBFAGwAcwBlAAoAewAKAFcAcgBpAHQAZQAtAEgAbwBzAHQAIAAiADEAIgA7AAoAfQA=’]
<192.168.56.102> WINRM RESULT <Response code 0, out "1 ", err “”>
<192.168.56.102> PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIhJRqZ TO C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\source
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIhJRqZ to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\source (offset=0 size=736)
<192.168.56.102> PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d TO C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=0 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=2037 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=4074 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=6111 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=8148 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=10185 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=12222 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=14259 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=16296 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=18333 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=20370 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=22407 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=24444 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=26481 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=28518 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=30555 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=32592 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=34629 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=36666 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=38703 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=40740 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=42777 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=44814 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=46851 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=48888 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=50925 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=52962 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=54999 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=57036 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=59073 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=61110 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=63147 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=65184 size=2037)
<192.168.56.102> WINRM PUT /var/folders/jb/1hrps5cs6ygggc41yly4pzpr5c632v/T/tmpIgJx1d to C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy (offset=67221 size=777)
<192.168.56.102> EXEC PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File “C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy.ps1”; Remove-Item "C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560" -Force -Recurse;
<192.168.56.102> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-EncodedCommand’, ‘UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARgBpAGwAZQAgACIAQwA6AFwAVQBzAGUAcgBzAFwAdgBhAGcAcgBhAG4AdABcAEEAcABwAEQAYQB0AGEAXABMAG8AYwBhAGwAXABUAGUAbQBwAFwAYQBuAHMAaQBiAGwAZQAtAHQAbQBwAC0AMQA0ADEAMAA5ADkANgA4ADQAMAAuADMANgAtADIANQAzADgAOQA3ADUAMQA0ADAAOQA1ADUANgAwAFwAXABjAG8AcAB5AC4AcABzADEAIgA7ACAAUgBlAG0AbwB2AGUALQBJAHQAZQBtACAAIgBDADoAXABVAHMAZQByAHMAXAB2AGEAZwByAGEAbgB0AFwAQQBwAHAARABhAHQAYQBcAEwAbwBjAGEAbABcAFQAZQBtAHAAXABhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADQAMQAwADkAOQA2ADgANAAwAC4AMwA2AC0AMgA1ADMAOAA5ADcANQAxADQAMAA5ADUANQA2ADAAXAAiACAALQBGAG8AcgBjAGUAIAAtAFIAZQBjAHUAcgBzAGUAOwA=’]
<192.168.56.102> WINRM RESULT <Response code 0, out “”, err “The argument 'C:\Use”>
failed: [192.168.56.102] => {“failed”: true, “parsed”: false}
The argument ‘C:\Users\vagrant\AppData\Local\Temp\ansible-tmp-1410996840.36-253897514095560\copy.ps1’ to the -File parameter does not exist. Provide the path to an existing ‘.ps1’ file as an argument to the -File parameter.
If there is a way to achieve this I would be interested to know. Thanks!