DSC DependsOn not working during initial run

Welcome Forums DSC (Desired State Configuration) DSC DependsOn not working during initial run

This topic contains 4 replies, has 3 voices, and was last updated by

 
Participant
6 months ago.

  • Author
    Posts
  • #101878

    Participant
    Points: 0
    Rank: Member

    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.

  • #101882

    Keymaster
    Points: 1,673
    Helping HandTeam Member
    Rank: Community Hero

    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.

  • #101888

    Participant
    Points: 0
    Rank: Member

    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?

    • #101929
      Syl

      Participant
      Points: 27
      Rank: Member

      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.

  • #101962

    Participant
    Points: 0
    Rank: Member

    @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.

The topic ‘DSC DependsOn not working during initial run’ is closed to new replies.