0
votes

I was wondering if the following scenario is supported:

We currently run multiple instances of the same applications on our servers. We've created a DSC configuration that specifies what our application needs so we can quicly set up an environment. Is it possible to compile this configuration multiple times with different parameters and push it to the target nodes?

Many thanks in advance

2

2 Answers

2
votes

Yes this is posible, you can have parameters in configuration and the result of that configuration would depend on the input

Configuration configure-me {
    Param(
        [bool]$iis
    )

    Import-DscResource -ModuleName PSDesiredStateConfiguration
    Node localhost {
        if ($iis) {
            WindowsFeatureSet Prereq {
                Name   = @( "Web-Server", "Web-WebServer",  )
                Ensure = "Present"
                Source = "C:\Windows\WinSxS"
            }
        }
    }
}

This configuration would do nothing if you pass in $false and would install IIS if you pass in $true

0
votes

The have the same setup of our application with different instances, the way to solve it is to wrap the needs of the application in a DSC custom resource and use that in the configuration document.

More info can be found on the following URL: https://docs.microsoft.com/en-us/powershell/dsc/authoringresourcecomposite