Specify a variable for a machine when you add it to an environment

Hi Octopus,

I basically want to achieve this -

  • At run time, the PS script will retrieve the machine name, that the script is currently being run on.
  • Now it will fetch a password for this machine. (I don’t want to create n variables, where there are n machines in my environment). It’s a brute force approach.
  • I want something which can fetch me machine specific variables, something which I can preferably set when I added the machine to Octopus environment. Can that be done?

If not, you would have probably inferred, I am hinting towards a hash-map kind of data structure. Any ideas on how I implement this on Octopus?

Hi there, thanks for the mail.

I’m not sure I understand what you’re looking for; if there’s a distinct password to be stored per machine, it sounds like a machine-scoped variable should be a perfect way to achieve this.

If not, please let me know what I’m missing - there might be another kind of variable scoping (e.g. per-role) that would help with this.

Cheers,
Nick

Hi Nik,

Thanks for the reply. We sorted that situation out. Variable scoping did help.
I am deploying a NuGet package now, as one of the deployment process steps. I see there is only the option of specifying the PackageId; I was wondering if we could aslo specify the PackageVersion along with the Id?

-Aj

Also, I have another question.

I want to move certain files from one machine to the other in the same environment. I am using “Copy-Item” to do so, but this seems intuitively wrong. Is there a way Octopus supports copying items between the environment machines?

-Aj

From: Kher, Ajinkya
Sent: Thursday, March 27, 2014 3:38 PM
To: 'support@octopusdeploy.com’
Subject: RE: Specify a variable for a machine when you add it to an environment [Questions #2059]

Hi Nik,

Thanks for the reply. We sorted that situation out. Variable scoping did help.
I am deploying a NuGet package now, as one of the deployment process steps. I see there is only the option of specifying the PackageId; I was wondering if we could aslo specify the PackageVersion along with the Id?

-Aj

Hi Aj,

Using Copy-Item is probably the right way to go, Octopus doesn’t build this in.

Regarding package version - this is controlled at the Release level (when you create releases of a project) rather than at the Project level. Let me know if this needs more clarification.

Cheers,
Nick

That’s surprising… So you put in the credentials, use net use, and then copy-item, to copy from a machine which Octopus can directly access… That’s a little unintuitive… Hopefully Octopus can introduce a direct way of doing this…
Thanks for the confirmation though…

-Aj

Also Nik, Is there a way I can get the current machine role the script is being run on as a variable?
There are a bunch of Octopus provided system variables but I don’t see machine role as one of them…

Hi Aj,

I want to move certain files from one machine to the other in the same environment. I am using “Copy-Item” to do so, but this seems intuitively wrong. Is there a way Octopus supports copying items between the environment machines?

Is it possible you can package the files in a NuGet package, and have Octopus distribute the package to the machines? Can you share some more information about the scenario and why you need to copy files from one machine?

We don’t currently expose variables for the current machine role - I’ve opened an issue here to add it in a future release:

Paul

Hi Paul,

Sure let me shed some more light on that…

So, consider we have a NuGet package,

  1. We bring in this NuGet package on our “Staging” machine.
  2. On this staging machine, we internally organize the different package versions into different directories.
  3. At run time, we request any particular version, fetch it from the “Staging” machine, and copy it over onto our “deployment” machines.

It is in step 3 that we really need the “copy between octopus machines” feature…

Hi Aj,

So is the question about whether it is possible to leverage the Octopus/Tentacle communication channel from your application, so you can say to Tentacle “Hey, go to this machine and request a file”?

I suppose one way to do it might be to have your application call octo.exe to trigger a deployment of the package to your server.

It’s not possible right now to tell Tentacles to do something without an Octopus server, and even if it was all comms would go via the Octopus server anyway (two Tentacles cannot talk directly to each other).

Hope that helps. It’s possible that I’ve completely misunderstood the scenario so if so please let me know. And let me know if you need more info on how the octo.exe solution might work.

Paul