Organizing and using multiple files for configuration

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Michael Willis Michael Willis 8 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #33731
    Profile photo of Michael Willis
    Michael Willis
    Participant

    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
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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
    Profile photo of Michael Willis
    Michael Willis
    Participant

    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.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.