OctopusDSC dynamically assign roles?

Hi, I posted this as an Issue on the OctopusDSC GitHub page, but asking here also.

How can I dynamically assign Tentacle roles at runtime?

In my scenario, I use a DSC cTentacleAgent resource to install and configure tentacles on several client servers, but the roles assigned each time depend on the client its running on, i.e. different client servers have different roles within Octopus, and I only know at runtime which they are.
I have a Script resource that can set the array variable of the Roles at runtime, but the cTentacleAgent block won’t resolve this at runtime.

For instance, something like this would be ideal:

DSC (in pseudocode …)

Script MyRoles {
SetScript {
If Server = “a”
$RolesToUse= @(“appserver”,“webserver”)
Else If Server = “a”
$RolesToUse= @(“opsserver”,“networkserver”)
TestScript { … }
GetScript { … }

cTentacleAgent OctopusTentacle {
Ensure = “Present”;
State = “Started”;
Name = “Tentacle”;
ApiKey = “API-12345678”;
OctopusServerUrl = “URL”;
Environments = @(“Dev”);
Roles = $RolesToUse; ## VARIABLE FROM ABOVE;
ListenPort = "10933"
DefaultApplicationDirectory = “c:\Applications”

The Script resource is executed at runtime on the client, so this $RolesToUse variable will be set correctly.
But the Roles property of cTentacleAgent seems to only resolve during MOF creation, and keeps that value when pulled down from clients.
Any way this can be set dynamically, or during a Tentacle client install ?

Many thanks!

Hi Bronwyn,

Closing this as I’ve replied on the github issue - https://github.com/OctopusDeploy/OctopusDSC/issues/33.