Evaluating Target Machine Roles from Variable Set Variable

pnolan's Avatar


21 Feb, 2018 06:39 AM

Some of our variables have outcomes that are conditional on the target machine belonging to a Role(s).

At the moment I have a Step (e5 - Set Pre-Deployment Variables) that runs at the start of a deploy which sets some step variables as follows

$roles = '#{Octopus.Machine.Roles}' -split ','
$Ise5FoundationWebServer = $roles -Contains 'e5foundation-web'
$Ise5FoundationAppServer = $roles -Contains 'e5foundation-app'
$Ise5ContentManager = $roles -Contains 'e5ContentManager'

Set-OctopusVariable -name "Ise5FoundationWebServer" -value $Ise5FoundationWebServer
Set-OctopusVariable -name "Ise5FoundationAppServer" -value $Ise5FoundationAppServer
Set-OctopusVariable -name "Ise5ContentManager" -value $Ise5ContentManager
Set-OctopusVariable -name "Ise5FoundationAppWebServer" -value $Ise5FoundationWebServer -and $Ise5FoundationAppServer

I then have a Variable within a Variable Set where the value is as follows

#{if Octopus.Action[e5 - Set Pre-Deployment Variables].Output.Ise5FoundationAppWebServer == "True"}#{e5.Foundation.Services.EndPoint.Origin.Local}#{/if}#{unless Octopus.Action[e5 - Set Pre-Deployment Variables].Output.Ise5FoundationAppWebServer == "True"}#{e5.Foundation.Services.EndPoint.Origin.Client}#{/unless}

The logic isn't overly relevant, what's important is that a value is determined based on whether the target machine belongs to two specific roles.

This all works fine. However, this won't work for an Offline Package Drop as from what I understand they do not currently support setting variables from a Step (although there is a highly rated UserVoice thread raised by Paul Stovell for this).

Is there any way I could evaluate if the machine I'm deploying to belongs to two target Roles within the syntax of a Variable Set Variable value?

Thanks heaps!

  1. Support Staff 1 Posted by Nick Josevski on 22 Feb, 2018 07:17 AM

    Nick Josevski's Avatar


    Thanks for getting in touch. We had idea there might be some meta-data you could use where the packages are dropped but after some experimenting/investigation there isn't anything there that would be suitable.

    So unfortunately it's not supported, we do have that user voice ticket https://octopusdeploy.uservoice.com/forums/170787-general/suggestio... all I can say is vote for it and add your example case there. But at the moment we're not looking to work on adding that feature that anytime soon.


Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac