Hi
I have a playbook that is running the below powershell script.
If I run the script on the actual server it works perfectly. But when I run the playbook nothing happens on the server.
The job returns as changed…but nothing has happened.
The playbook does seem to run quite quickly and I was wondering if Ansible is stopping the Powershell job before it completes? Can Ansible do that, or does it not have any effect on the script after it has been executed? If it does have an efffect on stopping the job are you able to put a wait on the job to allow the powershell script to complete?
$InstallPath = “C:\Program Files\Octopus Deploy\Tentacle”
$Server = $InstallPath + “\Tentacle.exe”
Start-Process “C:\Temp\Octopus.Tentacle.3.0.10.2278-x64.msi” /qn -Wait
Start-Process $Server ‘create-instance --instance “Tentacle” --config “C:\Octopus\Tentacle.config”’ -Wait
Start-Process $Server ‘new-certificate --instance “Tentacle” --if-blank’ -Wait
Start-Process $Server ‘configure --instance “Tentacle” --reset-trust’ -Wait
Start-Process $Server ‘configure --instance “Tentacle” --home “C:\Octopus” --app “C:\Octopus\Applications” --port “10933” --noListen “False”’ -Wait
Start-Process $Server ‘configure --instance “Tentacle” --trust “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”’ -Wait
Start-Process $Server ‘service --instance “Tentacle” --install --start’ -Wait
Cheers
Mark
Hmm, not sure what is going on there.
Try running with -v so you can see stdout from script module output
Also check the event log to see if there is anything there.
When run on the server do you have accept UAC prompt? Might need to turn that off to run remotely via ansible.
Hope this helps,
Jon
Hi Jon
I made sure the UAC was disabled on all servers, also went through the event viewer on the servers and there are no errors at all.
I ran the playbook with -vvvv and got the out put below. From what I can see there is nothing to indicate why the script isnt running? Can you see anything?
TASK [Configure Octopus Deploy] ************************************************
task path: /var/lib/awx/projects/Ansible Wintech Modules/windows/test_installocto.yml:5
<10.10.3.168> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.10.3.168
<10.10.3.167> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.10.3.167
<10.10.3.168> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name “ansible-tmp-1455274488.54-175087382503447”).FullName | Write-Host -Separator ‘’;
<10.10.3.167> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name “ansible-tmp-1455274488.55-16112873211253”).FullName | Write-Host -Separator ‘’;
<10.10.3.167> PUT “/var/lib/awx/projects/Ansible Wintech Modules/windows/files/octo_autoconfig.ps1” TO “C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1455274488.55-16112873211253\octo_autoconfig.ps1”
<10.10.3.168> PUT “/var/lib/awx/projects/Ansible Wintech Modules/windows/files/octo_autoconfig.ps1” TO “C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1455274488.54-175087382503447\octo_autoconfig.ps1”
<10.10.3.167> EXEC & “C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1455274488.55-16112873211253\octo_autoconfig.ps1”
<10.10.3.168> EXEC & “C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1455274488.54-175087382503447\octo_autoconfig.ps1”
<10.10.3.167> EXEC Set-StrictMode -Version Latest
Remove-Item “C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1455274488.55-16112873211253” -Force -Recurse;
<10.10.3.168> EXEC Set-StrictMode -Version Latest
Remove-Item “C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1455274488.54-175087382503447” -Force -Recurse;
changed: [10.10.3.167] => {“changed”: true, “invocation”: {“module_args”: {“_raw_params”: “files/octo_autoconfig.ps1”}, “module_name”: “script”}, “rc”: 0, “stderr”: “”, “stdout”: “”, “stdout_lines”: }
changed: [10.10.3.168] => {“changed”: true, “invocation”: {“module_args”: {“_raw_params”: “files/octo_autoconfig.ps1”}, “module_name”: “script”}, “rc”: 0, “stderr”: “”, “stdout”: “”, “stdout_lines”: }
PLAY RECAP *********************************************************************
10.10.3.167 : ok=2 changed=1 unreachable=0 failed=0
10.10.3.168 : ok=2 changed=1 unreachable=0 failed=0
[root@uk-ansible01 windows]# UAC
Cheers
Mark
Try with -vvvvvv ( 6 vs) which should show you the stdout / stderr from the script run.
I would be tempted to insert some lines like the following to see what progress, if any, your script is making:
Write-Host “Got here”
Actually - I did a little digging and found this page - http://help.octopusdeploy.com/discussions/problems/23239-unable-to-configure-tentacle-over-remote-powershell-session - looks like you might need to run tentacle with -console to stop it running a service when run remotely.
If that’s not it then things that might be relevant - powershell execution policy - if its not Unrestricted (which you should see with -vvvvvv that could be an issue).
Permissions, user rights - although I’d expect permission denied messages if its the former and probably something in the eventvwr if its user rights-related.
Hope this helps,
Jon