A modular approach to dynamic DSC configurations

How to deliver DSC configurations the modular way
Develop baseline processes to deploy and maintain DSC configurations on hundreds of systems for enterprise companies or reuse them for different customers as an MSP.
Picture of Ante

Ante

Table of contents

PowerShell DSC is a management platform in PowerShell that enables you to manage your IT and development infrastructure as configuration as code. As DSC uses a declarative syntax and PowerShell as a base, it quickly became one of the most popular configuration as code platforms.

With the increase in community-built modules that enhance functionality, some limitations and challenges were introduced. The biggest are probably the complexity of large configurations and the versioning of DSC modules and configurations.

To deploy DSC configurations and maintain them on hundreds of systems if you are an enterprise company, or to reuse the same baseline configurations for different customers if you are an MSP, you should develop some baseline processes. âś…

How can XOAP help you?

By combining different features, you can solve these challenges through three simple steps:

  1. Create a baseline DSC module using our DSC module template with all the settings you want to deploy as a baseline.
  2. Create configurations by combining baseline DSC resources and specific configurations for different departments or customers.
  3. Deploy configurations and install applications by combining configuration groups and application roles, and register your system (node) to the specific group.

Before we explain how to configure everything with XOAP, please check the following schema that displays the logic and relationships between the baseline module and configurations:

XOAP schema that displays the logic and relations between the baseline module and configurations

Configurations are declarative PowerShell scripts which define and configure resource instances.

Resources are the “make it so” part of DSC. They contain the code that puts and keeps the target of a configuration in the specified state.

In real-world situations, configurations can become long and complex, calling many different resources and setting a vast number of properties. To help address this complexity, you can use a Windows PowerShell Desired State Configuration (DSC) configuration as a resource for other configurations, so called DSC modules.

Modules combine multiple resources that can be dynamically integrated in different configurations.

The baseline module in the diagram defines resources that define specific settings for all customers or departments. These resources can be reused and separately integrated into different DSC configurations for specific use cases. 

Using modules to create sets of specific resources for certain use cases makes those modules reusable and dynamically assignable to different DSC configurations that reference the module and the specific resource inside this module.

With this approach, we have versioning on a module level. How do we get this up and running with XOAP? Let’s go! ⬇️

Step 1: Create a baseline DSC module

➡️ To create the baseline module, you can use our template available on GitHub.

Download the content, navigate to the download folder location, modify the following command with your values, and run:

.\New-CompositeResource.ps1 -Module ‘XOAPModuleTemplateDSC’ -Version ‘0.0.1’ -Resource ‘DSCResource’

This will create a folder structure like this:

XOAPModuleTemplate
          |
          |_0.0.1
                     |
                     |_DSCResources
                     |             |_DSCResoursce
                     |
                     |_Examples

In the DSCResource you can find two files: DSCResoursce.psd1 and DSCResoursce.schema.psm1.

Modify DSCResoursce.schema.psm1. file and insert your DSC configuration code into it.

Example:

				
					Configuration 'XOAPRemoteDesktopServicesDSC'
{
	Import-DSCResource -Module 'XOAPRemoteDesktopServicesDSC' -Name 'XOAP_RDSQuickStartConfiguration' -ModuleVersion '0.0.1'

    param
        (
            [string[]]$ConnectionBrokerServerName = 'connectionbroker.domain.com'
            [string[]]$SessionHostServerName = 'sessionhost.domain.com'
            [string[]]$AllowedUserGroup = 'domain\group'
        )

	        Node'XOAPRemoteDesktopServicesDSC'
	        {
            XOAP_RDSQuickStartConfiguration 'Example'
            {
                ConnectionBrokerServerName = $ConnectionBrokerServerName
                SessionHostServerName = $$SessionHostServerName
                AllowedUserGroup = $$AllowedUserGroup
            }
	         }
	        }
XOAPRemoteDesktopServicesDSC -OutputPath 'C:\XOAPRemoteDesktopServicesDSC'

				
			

The Import-DSCResource command enables you to load specific settings from other modules by defining the module name, the resource name and the version of the module.

More information on how to write DSC composite resources can be found here.

Once created, you need to upload the module to your XOAP workspace. More information on how to do this can be found on our documentation page.

Step 2: Create configurations

Next, create configurations combining your baseline DSC resources and specific configurations for different departments or customers.

To create configurations, navigate to the Configuration Management module and click +.

Create a configuration for your department or customer using resources from the uploaded module and combine it with other modules.

In the Configuration Wizard, click “Add Resources”, select the module, version and resource. In “Create New Resource”, fill in the required data:

Create new resource in XOAP

When you have filled in all the data, click Save to add the resource to the configuration.

To create a configuration, click Save and enter the version information. In the “Save Configuration” window, click Save when you’re ready.

Save configuration in XOAP wizard

More information on how to use the configuration wizard can be found in our docs.

Step 3: Assign configurations

To assign a configuration to multiple systems (nodes) use “Groups”.  To create a new group, navigate to Configuration Management > Groups and click +.

Groups option

In the “Add Group” window, enter the name of the group and select a “Configuration”, a specific “Version”, and a “Policy”. If you want to install applications on the systems, you can also select an “Application Role”.

Add groups in XOAP

By running the registration script or registration command on the nodes, you can add them to the group. The configuration will then be applied.

Groups options menu

For more info visit this documentation page.

Keeping configurations up to date

How to keep configurations up to date, or better yet, how to maintain them?

If you need to update customer-related configurations, navigate to “Configurations”, locate the specific configuration, and click on the action menu to Edit it.

Edit option in menu of Configurations

Every saved change to a configuration will create a new version. This version can be assigned to the groups you created earlier. As soon as you update the configuration version within the group, the assigned nodes will update their configurations based on the update interval specified in the assigned policy.

This enables you to assign specific versions of a configuration to a group and gives you control over which settings are applied. By creating different groups for test, acceptance and production you can create a process of delivering changes.

If you have updated your baseline module and uploaded a new version, navigate to the configuration and from the action menu, select Re-Compile.

Re-compile option in Configurations

This will open a “Re-Compile” window, where you can select the new version of your module.

Re-compile configuration in XOAP

Re-compiling will automatically save a new version of the configuration, integrating all updated resources from the module. Follow the steps described above to update the configuration version within your groups.

Improve your process today

XOAP enables you to create modular and dynamic configurations easily, combining resources from a baseline module with customer- or department-specific modules.

This minimizes human errors and enables a clear configuration management process with defined test procedures, as well as easy update and rollback capabilities.

If you want to learn more or need additional help getting started with specific use cases, you can book a demo. 🙌

Share post

More Posts

How to convert Group Policy into DSC with BaselineManagement module
Tutorials

Convert Group Policy into DSC

Easily convert Group Policy into DSC with BaselineManagement. Implement an IaC approach, essential for hybrid infrastructures.

Intune and MEM vs. XOAP, What's the difference
Company & culture

Intune & MEM vs. XOAP: What’s the difference?

Explore the differences between Intune, MEM, and XOAP. Consider whether sticking with familiar practices is really serving your organization’s needs.

Scroll to Top