Powershell Script not working when using PLaybook

Hi

I hae a playbook that runs a powershell script to configure an Octopus Deploy Tentacle.

If I run this powershell script on the server it works perfectly. If I run playbook with the powershell script it fails on the server.

What could possibly be causing this? Permissions? Timing out?

Playbook:

Have you checked the event viewer on the remote windows machine?

I haven’t used Octopus Deploy / Tentacle so don’t know if it is attempting any operations on remote machines during its installation. If so its possible you are hitting a ‘second hop’ issue - going from Ansible box to windows host A and from windows host A to windows host B is, roughly speaking, not allowed (with the connection methods available at the moment).

What error do you get when running the script via ansible (use -vvvvvv to extract full output from the windows machine)?

You can run
export ANSIBLE_KEEP_REMOTE_FILES=1
before running your playbook if you want to keep the files on the server, although this is usually only done to debug modules.

Probably best asking about the NullReferenceException via octopusdeploy’s site, although this issue here sounds a little like what you are encountering: http://help.octopusdeploy.com/discussions/problems/25989-nullreferenceexception-after-moving-octopus-server

Hope this helps,

Jon

Hi Jon

I had a look at the event viewer and saw that that it is getting an access is denied error (this happens for all commands in the powershell script):

2016-02-24 15:53:12.2675 1 FATAL System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I am running the playbook with the server admin account, so not sure why this is failing?

Is there a way of forcing the script to run with a specific administrator account so that it succeeds?

Cheers
Mark

A few comments on this:
The best way to troubleshoot stuff like this is not only to try and run the script locally, but also run it using a psremoting session from another machine. That will more closely mimic what Ansible is doing.

If there is a problem with the script quitting too soon you should be able to verify this by simply adding a start-sleep to the end of your script? If that solves it the root cause of the problem won’t have anything to do with Ansible, but with with Octopus.

As far as Administrators go, a default setup of windows will only allow members of the administrators group to access the server thru WinRM, and UAC is never invoked inside a WinRM session. So basically, you have as much permission as you possibly can on the machine.