1

I am just getting started with DSC and am trying to understand the best approach to applying different configs to different VMs in Azure. I am struggling with understanding how you certain settings to all machines and certain settings to just some of the machines. My first thinking was that for the ones I would apply to all machines I would have a config for those settings and just assign it to all machines and then another (separate) config for the settings I wanted to apply to just some of the machines and only assign it to the ones that needed it.

This would result in some machines having two configs applied and some machines only having a single config applied. But, it does not seem possible to apply that type of approach so now I am trying to figure out how to effect the multiple configs to get the result I am looking for.

If I can only have a single config file that gets applied to all machines, how do I tell some machines to apply setting A and all machines to apply setting B?

phydeauxman
  • 1,432
  • 3
  • 26
  • 48
  • [This is maybe not quite a duplicate, but is highly related](https://stackoverflow.com/q/46979902/3905079). I'm also not too familiar with DSC in Azure which from what I understand has some of its own unique aspects? But my answer on that other question talks about how you handle shared config in DSC generally. – briantist Feb 13 '19 at 00:39

1 Answers1

0

there are many answers to this question (composite configurations,partial configurations), or you could just use a single config with "feature" toggles:

Configuration X {
    Param(
         [bool]featureA = false
    )

    Node localhost {

    if ($featureA) {
            do something
        }

    }
}

another simple way is having 2-3-5 different configurations in the same file and applying the right one based on some arbitrary logic on a higher level (arm template).

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • But *how* /*where* do you change the feature flag?! This is a major thing about all DSC documentation that stymies me - you write a config for "localhost" (and not sure if you can ever write it for anything else?), great. Where the farfegneugen do I specify "If your hostname is in list A, do config A, if you're in list b (or an OU or whatever), do B. – Orangutech Sep 14 '21 at 15:00
  • you can do it in the if: `if ( $env:COMPUTERNAME -match x ) { xxx } else { yyy }` or you can use configuration file and conditions in the configuration – 4c74356b41 Sep 15 '21 at 06:44