Octopus.Environment.MachinesInRole is scoped to Machines in Deployment?

Hi,

Is this system variable supposed to be scoped to deployments too? I’m expecting the machines in the environment, but when I deploy to a subset of machines, the list is only those machines and not all in that environment.

/Matt

Hi Matt,

Thanks for getting in touch! This is the intended behavior of this variable. During a deployment, this variable is populated with the machines in the specified role that the deployment is running against, and won’t list machines outside of the subset you’re deploying to.

If you need all of the machines even when deploying to a subset of them, you can retrieve them via the API. We have a script available in our sample script repository to get this specific information I think you’re after. :slight_smile:

I hope this helps! Let me know how you go or if you have any further questions moving forward.

Best regards,

Kenny

Hi Kenny,

Thanks that’s what I thought. To be honest I think it’s still a little misleading as it’s in the Octopus.Envionment namespace and the documentation doesn’t mention anything about scoping to Deployments.

Might be worth mentioning in the docs if there’s going to be no code changes.

/Matt

Also what would be the best way of doing the same machine query, but within a process step? I don’t really want to do an API call nor store the key in a step template.

Hi Matt,

Thanks for following up and providing this input. I agree that the documentation on this specific variable should be made more clear, and I’ll make sure to clarify its description to avoid confusion in the future.

I understand the concern on having to store the key in a step template and having to do an API call, though unfortunately I don’t believe we have a better way to achieve this in the case of deploying to a subset of existing machines. These variables are only populated within the specific deployment’s context.

This would require a way to still deploy to all machines within a role, but since some machines are sometimes excluded I don’t see a way to automate that. You’d probably need a plan to change machine roles before deploying, and/or change step scoping before creating your release. Both of which don’t sound ideal.

I’m sorry it’s not better news! Let me know if you have any questions or concerns moving forward.

Best regards,

Kenny

Hi Kenny,

No more questions thanks, you’ve been very helpful!

/Matt

Hi Matt,

You’re very welcome! Glad to be of help. :slight_smile:

Don’t hesitate to reach out if you have any questions or concerns in the future!

Best regards,

Kenny

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.