Author Posts

June 6, 2018 at 12:39 am

Hi Guys

I'm busy testing some DSC Configs and it looks like the DependsOn property is not being adhered to during a run of DSC.

My Composite Resource looks like this:

  
        cChocoPackageInstaller $Package1
        {
            Name                 = $("$Package1_" + $Package1Version)
            Version              = $Package1Version
            Source               = 'nexusrepo'
            chocoParams          = "--pre --force"
            Params               = $Params
            PsDscRunAsCredential = $DomainCredentials

        }
        cChocoPackageInstaller $Package2
        {
            Name                 = $("$Package2_" + $Package2Version)
            Version              = $Package2Version
            Source               = 'nexusrepo'
            DependsOn            = "[cChocoPackageInstaller]$Package1"
            chocoParams          = "--pre --force"
            Params               = $Params
            PsDscRunAsCredential = $DomainCredentials 

Does DSC do a Test-TargetResource in between applying resources?

Thanks for the help.

June 6, 2018 at 1:11 am

DependsOn and composites get a little weird. That's especially true when you're non-deterministic, as when using variables for resource names. Composites can be a wee bit delicate in some ways.

You could enable a trace, and then check the Debug logs for DSC on the node. That'd give you more detail about what's happening and when it's happening.

June 6, 2018 at 4:05 am

Thanks Don

I enabled debugging and stepped through the deployment it can't find anywhere that DependsOn is used before the next package is executed.

My thinking is that DependsOn doesn't care if a resource is in a valid state it only ensures that the resources are executed in the correct order.

How does DSC then stop if one resource fails?

June 6, 2018 at 3:41 pm

In my experience, DependsOn really do care if a required resource complete successfully. In one of our configuration, SQL didn't even tr to install because one of it's dependency had an error while installing.

June 6, 2018 at 7:49 pm

@Syl you might be correct what I'm thinking then is, when DSC does a run it will only stop if a specific resource's "Set-TargetResource" throws an error. It doesn't do a "Test-TargetResource" directly after it has completed a "Set-TargetResource"

I'll try and do a bit more investigation into this today.