Continuous Improvement for Software Engineers

Instructions, notes and guides to help with continuous software improvement.

View on GitHub

Desired State Configuration using PowerShell Core

Apply settings to an operating system without defining how those values are actually configured. Enables the creation of Servers as “Cattle”, not “Pets” and ensures that manual changes to the server do not cause “drift”. It provides a compliance and automated repair back to a known good state.

# Install IIS role
WindowsFeature IIS
{
    Ensure = "Present"
    Name = "Web-Server"
}
# On windows OS - Display the enabled features.
Get-WindowsOptionalFeature -Online | Where-Object {$_.State -eq 'Enabled'}

# On Server OS
Get-WindowsFeatures

# List Resources
Get-DSCResource

# Find and install DSC resource Kit.
Find-Module -tag dscresourcekit | Install-Module

Desire State Process

  1. Author the desired state and generate a *.mof file which is the DMTF standard. See Standards Documents
  2. Stage the desired state configuration for pull or push publishing.
  3. Apply the configuration to the infrastructure/server. Idempotent, so anyone manually changing settings will have those reverted.

Configuration Options

Basic Commandlets

Set-ExecutionPolicy unrestricted -Force
Enable-PSRemoting -Force
Install-Module -Name xWebAdministration
# Push Model
Start-DSCConfiguration -Wait -Verbose -Path
# Pull Model
Get-DSCConfiguration
# Review Drift
Test-DSCConfiguration -Detailed

More Detailed walk through for onpremise example - Github - JohnTheBrit

Using LocalHost in configuration may not behave as you expect

File Example

File CriticalFileExample
{
    Ensure = "Present"
    Type = "Directory"
    Recurse = $true
    MatchSource = $true
    SourcePath = "d:\VIP\Source"
    DestinationPath = "c:\VIP\Target"
}

DSC and Cloud

References