What ansible version are you using?  If I recall we had a problem in the 
past with execution policy being set differently under some circumstances, 
which I speculate might be causing your problems.

As a 'get-you-going' suggestion, you could try running the problematic 
commands (without the start-process) using the 'raw' module.

Hope this helps, let us know how you get on.

Jon

On Thursday, July 30, 2015 at 9:36:42 PM UTC+1, O haya wrote:
>
> Hi,
>
> FYI, I've also tried changing from using Start-Process to Invoke-Command, 
> but it still seems to do the same thing (hangs) when I try to run the ps1 
> via Ansible.  I don't know if this'll help, but here's the output with 
> -vvvv:
>
> Enter code here...
> [root@centos65 ansible_test]# ansible windows -i host -m installit -vvvv
> <ansibleclient1.whatever.com> ESTABLISH WINRM CONNECTION FOR USER: 
> administrator on PORT 5985 TO ansibleclient1.whatever.com
> <ansibleclient1.whatever.com> WINRM CONNECT: transport=plaintext endpoint=
> http://ansibleclient1.whatever.com:5985/wsman
> <ansibleclient1.whatever.com> REMOTE_MODULE installit
> <ansibleclient1.whatever.com> EXEC (New-Item -Type Directory -Path 
> $env:temp -Name "ansible-tmp-1438288265.32-170673722533874").FullName | 
> Write-Host -Separator '';
> <ansibleclient1.whatever.com> WINRM EXEC 'PowerShell' ['-NoProfile', 
> '-NonInteractive', '-EncodedCommand', 
> 'KABOAGUAdwAtAEkAdABlAG0AIAAtAFQAeQBwAGUAIABEAGkAcgBlAGMAdABvAHIAeQAgAC0AUABhAHQAaAAgACQAZQBuAHYAOgB0AGUAbQBwACAALQBOAGEAbQBlACAAIgBhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADQAMwA4ADIAOAA4ADIANgA1AC4AMwAyAC0AMQA3ADAANgA3ADMANwAyADIANQAzADMAOAA3ADQAIgApAC4ARgB1AGwAbABOAGEAbQBlACAAfAAgAFcAcgBpAHQAZQAtAEgAbwBzAHQAIAAtAFMAZQBwAGEAcgBhAHQAbwByACAAJwAnADsA']
> <ansibleclient1.whatever.com> WINRM RESULT <Response code 0, out 
> "C:\Users\Administrat", err "">
> <ansibleclient1.whatever.com> PUT /tmp/tmpJaC2C3 TO 
> C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1438288265.32-170673722533874\\installit
> <ansibleclient1.whatever.com> WINRM PUT /tmp/tmpJaC2C3 to 
> C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1438288265.32-170673722533874\\installit.ps1
>  
> (offset=0 size=2030)
> <ansibleclient1.whatever.com> WINRM PUT /tmp/tmpJaC2C3 to 
> C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1438288265.32-170673722533874\\installit.ps1
>  
> (offset=2030 size=2030)
> <ansibleclient1.whatever.com> WINRM PUT /tmp/tmpJaC2C3 to 
> C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1438288265.32-170673722533874\\installit.ps1
>  
> (offset=4060 size=2030)
> <ansibleclient1.whatever.com> WINRM PUT /tmp/tmpJaC2C3 to 
> C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1438288265.32-170673722533874\\installit.ps1
>  
> (offset=6090 size=2008)
> <ansibleclient1.whatever.com> PUT /tmp/tmputTM97 TO 
> C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1438288265.32-170673722533874\\arguments
> <ansibleclient1.whatever.com> WINRM PUT /tmp/tmputTM97 to 
> C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1438288265.32-170673722533874\\arguments
>  
> (offset=0 size=2)
> <ansibleclient1.whatever.com> EXEC PowerShell -NoProfile -NonInteractive 
> -ExecutionPolicy Unrestricted -File 
> C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1438288265.32-170673722533874\\installit.ps1
>  
> C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1438288265.32-170673722533874\\arguments;
>  
> Remove-Item 
> "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1438288265.32-170673722533874\"
>  
> -Force -Recurse;
> <ansibleclient1.whatever.com> WINRM EXEC 'PowerShell' ['-NoProfile', 
> '-NonInteractive', '-EncodedCommand', 
> 'UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARgBpAGwAZQAgAEMAOgBcAFUAcwBlAHIAcwBcAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAXABBAHAAcABEAGEAdABhAFwATABvAGMAYQBsAFwAVABlAG0AcABcAGEAbgBzAGkAYgBsAGUALQB0AG0AcAAtADEANAAzADgAMgA4ADgAMgA2ADUALgAzADIALQAxADcAMAA2ADcAMwA3ADIAMgA1ADMAMwA4ADcANABcAFwAaQBuAHMAdABhAGwAbABpAHQALgBwAHMAMQAgAEMAOgBcAFUAcwBlAHIAcwBcAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAXABBAHAAcABEAGEAdABhAFwATABvAGMAYQBsAFwAVABlAG0AcABcAGEAbgBzAGkAYgBsAGUALQB0AG0AcAAtADEANAAzADgAMgA4ADgAMgA2ADUALgAzADIALQAxADcAMAA2ADcAMwA3ADIAMgA1ADMAMwA4ADcANABcAFwAYQByAGcAdQBtAGUAbgB0AHMAOwAgAFIAZQBtAG8AdgBlAC0ASQB0AGUAbQAgACIAQwA6AFwAVQBzAGUAcgBzAFwAQQBkAG0AaQBuAGkAcwB0AHIAYQB0AG8AcgBcAEEAcABwAEQAYQB0AGEAXABMAG8AYwBhAGwAXABUAGUAbQBwAFwAYQBuAHMAaQBiAGwAZQAtAHQAbQBwAC0AMQA0ADMAOAAyADgAOAAyADYANQAuADMAMgAtADEANwAwADYANwAzADcAMgAyADUAMwAzADgANwA0AFwAIgAgAC0ARgBvAHIAYwBlACAALQBSAGUAYwB1AHIAcwBlADsA']
>
>
>
>
>
>
> On Thursday, July 30, 2015 at 3:33:46 PM UTC-4, O haya wrote:
>>
>> Hi,
>>
>> It seems like when the .ps1 is run under Ansible, the two lines with 
>> "Start-Process" are not executing.  The first one, which runs setup.exe is 
>> supposed to cause copying the Sharepoint files, etc. and then the second is 
>> supposed to run psconfig.exe.
>>
>>
>> I've also tried modifying the ps1 file to eliminate the "Start-Process" 
>> and then run the playbook again, but it seems to hang.  I can tell because 
>> when this script runs normally (not with Ansible) it creates some 
>> directories and files on E:, but when i run under Ansible, nothing is being 
>> created on E:.
>>
>> Thanks,
>> Jim
>>
>>
>> On Thursday, July 30, 2015 at 2:17:55 PM UTC-4, O haya wrote:
>>>
>>> Hi,
>>>
>>> I have started trying to replicate some of the things that we are 
>>> currently doing with Chef, but with Ansible.  One of these is installing 
>>> Microsoft Sharepoint (on Windows 2008 R2).
>>>
>>> In Chef, I do this using some Powershell scripting, so I am trying to do 
>>> that with Ansible.
>>>
>>> I am using this simple Playbook which I found and modified to run a 
>>> Powershell script:
>>>
>>> ---
>>> # This playbook tests the script module on Windows hosts
>>>
>>> - name: Run powershell script
>>>   hosts: windows
>>>   gather_facts: false
>>>   tasks:
>>>     - name: Run powershell script
>>>       script: scripts/install.ps1
>>>
>>>
>>> The install.ps1 looks something like:
>>>
>>> dism /Online /quiet /Enable-Feature ...
>>>
>>> cd c:\Sharepoint2007SP2files
>>>
>>> echo "About to run setup.exe..."  >> c:/install-SHAREPOINT2007FULL.log
>>>
>>> Start-Process ./setup.exe -ArgumentList ... -Wait >> 
>>> c:/install-SHAREPOINT2007FULL.log
>>>
>>> echo "About to CD..."  >> c:/install-SHAREPOINT2007FULL.log
>>>
>>> cd "C:/Program Files/Common Files/Microsoft Shared/Web Server 
>>> Extensions/12/BIN/"
>>>
>>> echo "About to run psconfig.exe..."  >> c:/install-SHAREPOINT2007FULL.log
>>>
>>> Start-Process -FilePath ./psconfig.exe -ArgumentList ... -Wait >> 
>>> c:/install-SHAREPOINT2007FULL.log
>>>
>>> echo "ALL DONE!!"  >> c:/install-SHAREPOINT2007FULL.log
>>>
>>>
>>> When I try to run the Playbook using Ansible, I get this:
>>>
>>> PLAY [Run powershell script] 
>>> **************************************************
>>>
>>> TASK: [Run powershell script] 
>>> *************************************************
>>> changed: [ansibleclient1.whatever.com]
>>>
>>> PLAY RECAP 
>>> ********************************************************************
>>> ansibleclient1.whatever.com : ok=1    changed=1    unreachable=0   
>>>  failed=0
>>>
>>>
>>> And that completes almost immediately, and when I look at that log file, 
>>> I see the output messages, but it looks like the actual installation steps 
>>> that are supposed to run under "Start-Process" are not being invoked at 
>>> all.  I can tell this is the case because files that are supposed to be 
>>> created during the Setup.exe and psconfig.exe runs are not being created.
>>>
>>> I ran the same Powershell script "manually" and it works 
>>> correctly/completely.
>>>
>>> Does anyone know why these commands are being skipped when this 
>>> Powershell script is run under Ansible?
>>>
>>> Thanks,
>>> Jim
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f2a11c6e-c688-4493-8d28-18997831a224%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to