Organizing and using multiple files for configuration

Welcome Forums DSC (Desired State Configuration) Organizing and using multiple files for configuration

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

 
Participant
3 years, 4 months ago.

  • Author
    Posts
  • #33731

    Participant
    Topics: 7
    Replies: 11
    Points: 0
    Rank: Member

    I'm looking for some tips on organizing dsc configurations.
    Instead of writting one giant configuration I would like to break them into smaller-individual scripts.

    Such as writting individual configurations like:
    `
    Configuration WebServer {}
    Configuration WindowsFeatures {}
    Configuration Applications {}
    `

    My typical configuration is broken into 3 files:

    The configuration:
    `
    Configuration SetupInstall
    {
    param (...)

    Import-DSCResource -ModuleName xPSDesiredStateConfiguration

    Node $AllNodes.where{ $_.Role.Contains("Production") }.NodeName
    {
    # Resources added here...
    }

    }
    SetupInstall -ConfigurationData "configData.psd1" -PackagePath "\\..."
    `

    the config data:
    `
    @{
    AllNodes = @(
    @{
    NodeName="*"
    }
    @{
    NodeName = "Example"
    Role = "Production"
    TempFolder = "c:\dsc"
    }
    );
    }
    `

    The command to manually run the configuration until we use a pull server:
    `
    Start-DscConfiguration -Path .\SetupInstall -Verbose -Wait -Force
    `

    I would like to break the configurations into multiple files and still run one command to start the configuration.

    If this is not clear imagine a scripting language like PHP:

    // FileName: Config.php
    include('web-config.php');
    include('app-config.php');
    include('db-config.php');

  • #33733

    Member
    Topics: 9
    Replies: 2322
    Points: 0
    Rank: Member

    What you're describing is called a composite resource. With these, you can actually use DSC configurations as though they were resources. The configurations are given a param block (which defines what you can pass in when calling them from your outermost configuration), and they go under the DscResources folder structure of a module (in a file ending with .schema.psm1 ). See http://blogs.msdn.com/b/powershell/archive/2014/02/25/reusing-existing-configuration-scripts-in-powershell-desired-state-configuration.aspx for more information.

  • #33741

    Participant
    Topics: 7
    Replies: 11
    Points: 0
    Rank: Member

    I've created one simular to this for 7-zip which uses the set, test, and get-targetresource.They seem to have quite a bit of overhead for setting up. I may need to look into the deployment options for these resources to automate the installation of the modules from the repo to the server. I've seen some example with WMF 5 which uses classes to simplify some of this config.

The topic ‘Organizing and using multiple files for configuration’ is closed to new replies.

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