für was, wen, wann und überhaupt? DEVOP PART IV: DSC – DESIRED STATE CONFIGURATION
Dank DSC werden viele Administratoren nicht einmal mehr Powershell lernen müssen…
DSC ist komplett Textfile basierend – jeder kann es lesen, indexieren, anpassen und generieren.
DSC Architektur
Evolution des DevOps Basic Admin Scripter Programmierer
Configuration Scripts Configuration MonitoringSoftware { param( [string[]]$ComputerName="localhost" ) Node $ComputerName { File MonitoringInstallationFiles { Ensure = "Present" SourcePath = "\\dc01\Software\Monitoring" DestinationPath = "C:\Temp\Monitoring" Type = "Directory" Recurse = $true } MonitoringSoftware
Configuration Examples…
Registry Registry RegistryExample { Ensure = "Present" # You can also set Ensure to "Absent" Key = "HKEY_LOCAL_MACHINE\SOFTWARE\ExampleKey" ValueName ="TestValue" ValueData ="TestData" }
Package Resource Package PackageExample { Ensure = "Present" # You can also set Ensure to "Absent" Path = "$Env:SystemDrive\TestFolder\TestProject.msi" Name = "TestPackage" ProductId = "663A E0-4C48-898B-53D73CA2C14B" }
Umgebungsvariablen Environment EnvironmentExample { Ensure = "Present" # You can also set Ensure to "Absent" Name = "TestEnvironmentVariable" Value = "TestValue" }
Archiv Ressource Archive ArchiveExample { Ensure = "Present" Path = "C:\Users\Public\Documents\Test.zip" Destination = "C:\Users\Public\Documents\ExtractionPath" }
Windows Feature WindowsFeature IIS { Ensure = "Present" # To uninstall, set Ensure to "Absent" Name = "Web-Server“ # Name property from Get-WindowsFeature }
Gruppen Group GroupExample { # This will remove TestGroup, if present # To create a new group, set Ensure to "Present" Ensure = "Absent" GroupName = "TestGroup" }
Dienste Service ServiceExample { Name = "TermService" StartupType = "Manual" }
Script Ressource Script ScriptExample { SetScript = { $sw = New-Object System.IO.StreamWriter("C:\TempFolder\TestFile.txt") $sw.WriteLine("Some sample string") $sw.Close() } TestScript = { Test-Path "C:\TempFolder\TestFile.txt" } GetScript = { } }
Fehlt noch was…? Programmierer Scripter Basic Admin
DSC Resource Design
Resource Prototype
…da gibts noch was… Riesige Sammlung von Ressourcen von Microsoft:
Fehlt ein CMDlet…? Programmierer Scripter Basic Admin
Abgrenzung zu GPO’s? Über Domänengrenzen hinweg anwendbar Erweiterbarkeit durch eigene PS-Scripts Standardisiertes Format
DSC vs. GPO FeatureGroup PolicyDSC Configuration stored inGPO fileConfiguration script / MOF file Target nodes by means ofAD links to OUs, sites, etc.Configuration specifies node names Configuration implemented byClient-side OS componentsClient-side shell scripts (resources) Extensible by means ofComplex native programmingWindows PowerShell scripts Primary configuration targetWindows registry Anything Windows PowerShell can “touch” PersistenceSettings reapply each timeSettings are persistent Number of configurations per nodeAs many GPOs as you want to linkOne
Was passiert, wenn GPOs und DSC gleichzeitig im Einsatz sind…?
…eine Anleitung… Ich habe die Configurations gemacht – und jetzt?
Jetzt benötigen wir zuerst ein MOF! MOF = Managed Object Format
Weshalb ein MOF? Generisches File Format Wird auch von Unix und NW-Komponenten unterstützt Kann auch durch andere Tools (nicht PS) generiert werden
Wie mache ich ein MOF? …indem einfach der Name der CONFIGURATION aufgerufen wird…
Wie sieht ein MOF @GenerationDate=11/24/2015 */ instance of MSFT_RoleResource as $MSFT_RoleResource1ref { ResourceID = "[WindowsFeature]IIS"; Ensure = "Present"; SourceInfo = "::7::1::WindowsFeature"; Name = "Web-Server"; ModuleName = "PsDesiredStateConfiguration"; ModuleVersion = "1.0"; ConfigurationName = "ContosoWebsite"; }; instance of OMI_ConfigurationDocument { Version="2.0.0"; MinimumCompatibleVersion = "1.0.0"; CompatibleVersionAdditionalProperties={"Omi_BaseResource:ConfigurationName"}; Author="Administrator"; GenerationDate="11/24/ :56:05"; GenerationHost="GM15-SRV01"; Name="ContosoWebsite"; }; Configuration ContosoWebsite { Node GM15-SRV07 { WindowsFeature BasicWebServerComponents { Ensure = "Present" Name = "Web-Server" } CONFIGURATIONMOF
Wie kommt das MOF nun auf die Rechner?
PUSH oder PULL?
PUSH Zentral auf die Rechner verteilen: Start-DSCConfiguration –path.\ContosoWebsite –computername GM15-SRV07
PULL Praktikabler in produktiven Umgebungen Über…: HTTP/HTTPS (!!!) SMB
It’s all about…
DEMO: DSC