'DependsOn' property ignored in custom resource

Welcome Forums DSC (Desired State Configuration) 'DependsOn' property ignored in custom resource

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

ian
 
Participant
3 years, 10 months ago.

  • Author
    Posts
  • #26597
    ian

    Participant
    Points: 0
    Rank: Member

    I have created a custom resource 'SyncShare' and I can get it to run with expected results if I copy the resource folder to the modulepath on the target node. However, if I try to combine copying that resource to the target and applying it in a single configuration ( see below), the LCM on the target says that the resource isn't in the psmodulepath –despite the fact that I have used the 'DependsOn' property to ensure that the directory exists. In fact, the custom resource is not respecting the dependsOn property at all, since I find that it is always being evaluated before the file resource that would make that resource available. See this configuration fragment:

    File Resource_SyncShare
    {
    Type = "Directory"
    DestinationPath = $Node.ResourceRootPath+"\SyncShare"
    SourcePath = $Node.ResourceSourcePath+"\SyncShare"
    Ensure = "Present"
    MatchSource = $True
    Recurse = $True
    Force = $True
    Credential = $Credential
    Checksum = "modifiedDate"
    }

    SyncShare Tools
    {
    Name = "Tools"
    SourceDirectory = $Node.ToolsDirSourcePath
    DestinationDirectory = $Node.ToolsDirDestinationPath
    ChecksumFileName = "sync.checksum"
    Ensure = "Present"
    DependsOn = "[File]Resource_SyncShare"
    }

  • #26598

    Member
    Points: 0
    Rank: Member

    The LCM is probably reading the whole file and making sure that the resources exist before it starts to actually execute anything. You won't be able to distribute the resources that way.

    If you're using a pull server, don't worry about it, as the resources will be downloaded from there on an as-needed basis. If you're using Push deployments, then you'll need to copy out the necessary resources just before you execute Start-DscConfiguration.

    In PowerShell v5, you can do a hybrid of the two, where a pull server is used to download resources, but you can still apply configurations with a push via Start-DscConfiguration.

  • #26601

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

    Correct: the LCM pre-scans the file to make sure it has every resource needed before it processes anything. And, as Dave notes, it'll then grab modules from a pull server, if so configured. So you can't use a config to file-copy a resource AND use that resource. This is essentially what a pull server is meant to help solve.

  • #26635
    ian

    Participant
    Points: 0
    Rank: Member

    Thanks for the reply. I'm going to wait on setting up a pull server in prod until WMF5 is in GA.

The topic ‘'DependsOn' property ignored in custom resource’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort