0
votes

I have 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:
---
- name: Configure Octopus Deploy Tentecle
  hosts: all
  tasks:
    - name: Configure Octopus Deploy Tentecle
      script: files/octo_autoconfig.ps1

PowerShell script:

& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" create-instance --instance "Tentacle" --config "C:\Octopus\Tentacle.config" --console;
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" new-certificate --instance "Tentacle" --if-blank --console;
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" configure --instance "Tentacle" --reset-trust --console;
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" configure --instance "Tentacle" --home "C:\Octopus" --app "C:\Octopus\Applications" --port "10933" --noListen "False" --console;
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" configure --instance "Tentacle" --trust "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" --console;
& "C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe" service --instance "Tentacle" --install --start --console;

Error I get when I try open Octopus Tentacle after running the playbook to config Octopus:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Octopus.Tools.TentacleConfiguration.TentacleManager.TentacleManagerModel.Reload(ApplicationInstanceRecord applicationInstance) in y:\work\refs\heads\master\source\Octopus.Tools\TentacleConfiguration\TentacleManager\TentacleManagerModel.cs:line 131
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Note that if I run the PowerShell script directly on the server it works perfectly and configures the tentacle. If I then remove the tentacle and then run the playbook it works. So its as if the tentacle needs to be configured first directly on the server before an Ansible playbook can work. Which kind of defeats the point.

I had a look at the event viewer of the server and there were a few Access Denied errors, like the one below.

Is there a way of running this script with a specific admin user so that there is no access denied errors?

2016-02-24 15:53:12.2675      1 FATAL  System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at Octopus.Shared.Internals.CertificateGeneration.Win32ErrorHelper.ThrowExceptionIfGetLastErrorIsNotZero() in y:\work\refs\heads\master\source\Octopus.Shared\Internals\CertificateGeneration\Win32ErrorHelper.cs:line 13
   at Octopus.Shared.Internals.CertificateGeneration.CryptContext.Open() in y:\work\refs\heads\master\source\Octopus.Shared\Internals\CertificateGeneration\CryptContext.cs:line 38
   at Octopus.Shared.Security.CertificateGenerator.Generate(String fullName, Boolean exportable) in y:\work\refs\heads\master\source\Octopus.Shared\Security\CertificateGenerator.cs:line 27
   at Octopus.Shared.Configuration.TentacleConfiguration.GenerateNewCertificate() in y:\work\refs\heads\master\source\Octopus.Shared\Configuration\TentacleConfiguration.cs:line 188
   at Octopus.Tentacle.Commands.NewCertificateCommand.Start() in y:\work\refs\heads\master\source\Octopus.Tentacle\Commands\NewCertificateCommand.cs:line 58
   at Octopus.Shared.Startup.AbstractCommand.Octopus.Shared.Startup.ICommand.Start(String[] commandLineArguments, ICommandRuntime commandRuntime, OptionSet commonOptions) in y:\work\refs\heads\master\source\Octopus.Shared\Startup\AbstractCommand.cs:line 58
   at Octopus.Shared.Startup.ConsoleHost.Run(Action`1 start, Action shutdown) in y:\work\refs\heads\master\source\Octopus.Shared\Startup\ConsoleHost.cs:line 36
1

1 Answers

0
votes

I think you're hitting this error on the new-certificate step.

http://docs.octopusdeploy.com/display/OD2/Export+and+import+Tentacle+certificates+without+a+profile

You'll need to generate a cert and upload it to the target to import with the Tentacle.