How can we share a tentacle work dir btw diff steps

Hello Team,

We are using octopus deploy for a complex multiserver deployment, these are based on Linux and we use Tentacles.

We are trying to port the deployment logic to octopus and want to know if we can achieve below steps:

  1. Prepare workspace:
    where we download a package that has core ansible playbooks, create the dynamic host inventory baes on env and parameters.

  2. Deploy package 1
    Here we need to make use of the scripts that were created in above step to connect to hots and other pre package activites and deploy.

3 deploy package 3
Same, reuse the dynamic inventory created on step 1 and other dynamic files and deploy package x on servers

Each steps have a diff package, which will not have ansible playbooks created in step 1.

Issue is the tem work dir gets deleted after first step execution. Can we control this?
Or is there any other option we have?

Though of deploy package and using a custom installation dir, but this will lead to a manual dir creation and maintenance outside of work dir.

Is there a way octopus can create a dir based on release/run for custom installation dir and can be used to store all the playbooks required for each steps to be executed?

Quick response will help us a lot.
Thank you.

Hi @nagaharshithm,

Firstly, welcome to the Octopus community, it is great to see you here.

Thank you for reaching out to us with your questions.

If I have understood this correctly, what you could look to do is the following:

Step 1) Deploy your Ansible scripts in a package to your deployment target(s).

Step 2) From your next steps (and any other following steps that reference your scripts), you can programmatically (with your preferred scripting language) script this to get the Install path using the Octopus System Variables. Note, Octopus wont know the path until Step 1 has completed, so it will need to be in a new step to get the value of the system variable.

A simple overview would look like this:

$OctopusParameters["Octopus.Action[Deploy A Package].Output.Package.InstallationDirectoryPath"]

As the install path is being dynamically created for your deployments within Octopus, you could take advantage of system variables here.

For reference, my output resembles the following:

For all your steps that you need to reference your scripts, as long as they are running on the same deployment target you could reference your scripts this way using the variable.

Please note here that for each step you run within Octopus, a new PowerShell session is used, so you would need to set the variable in each step that needs to use your install path.

As long as the scripts are available on the deployment target you could in theory use this method.

This would help to avoid using the Custom Install Directory and avoid any additional maintenance from your side.

Just in case you haven’t seen this, there is a Blog post that explore an approach with Ansible.

I hope this helps get you where you need to be.

Many Thanks

Hello Doug,

Thank you for the details. Got clarified on few points.

As you described, we are amkeing use of deployment targets(Tentacle) installation.

As part of Step 1, deploy package octopus will download the nuget package and extract under a folder like Work/date-taskid-number.Once step 1 is finished, this work dir gets cleanup.

Is there way we can say octopus to retain this work dir till other steps are executed?

If so, we can make us of the variables to access these paths.

If it’s a custom dir, it will be again a overhead to ensure we purge in case of any hung deployments etc …

Hi @nagaharshithm,

When it comes to the working directory this is the expected behavior and cant be changed I am afraid.

With the above suggestions I made, your package will be extracted to the “InstillationDirectoryPath” so your scripts should become available there.

See below:

(This is on my Windows Tentacle but this will be similar to Linux for the “InstillationDirectoryPath”).

Just to mention, as long as you have your Retention Policies set up, Octopus will handle the clean up.

I wouldn’t recommended doing this, but to highlight, there is the possibility to copy the working directory to another location. This is usually used for debugging purposes only. I would also warn that "the copied directory will include a file which contains the secret one-time key passed to Calamari to decrypt the sensitive variables used in the deployment.

This directory (or at least the Variable.secret file) should be deleted once no longer required".

I would avoid doing that personally as it is not a sustainable solution.

This would require a cleanup managed by yourselves.

Apologies if I am misunderstanding your question, but I feel that my original suggestion should help you to get where you need to be (or close to it).

I hope this has helped.