einführung in desired state configuration › wp-content › uploads › ...microsoft: cim windows...

39
Einführung in Desired State Configuration PS UG Treffen 23.Feb 2017 MS Wien Roman Stadlmair

Upload: others

Post on 29-Jun-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Einführung in

Desired State Configuration

PS UG Treffen 23.Feb 2017

MS Wien

Roman Stadlmair

Page 2: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Agenda

Wozu DSC ?

Vorwissen

Vorausetzungen

Einführung in die Technologie

Loslegen !

Push und Pull Modi

Local Config Manager

Azure und DSC

Links

Page 3: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Wozu DSC?

Page 4: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Konfigurieren von Computern

Hingehen

RDP ==> Änderungen durchführen

Login Scripts

Startup-Scripts

Group Policy

Weitere …

Page 5: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Multi-Alles-Welt

Core-Server, Nano-Server

Linux/Windows/Xnix

Agile, DevOps, XaaS

Standardisierung Automatisierung

Linux-Welt:

Puppet: https://puppet.com/

Chef: https://www.chef.io/

Page 6: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Vorwissen

Page 7: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

DSC baut auf den folgenden Technologien

Windows PowerShell

Windows Remote Management (WinRM)

Common Information Model (CIM)

Management Object Format (MOF)

Page 8: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

WinRM

Microsofts Implementierung von „Web Services for

Management“ (WSMan)

„winrm“ Service (Default ON ab Domain joined > Win2012

Server)Get-Command –Module Microsoft.WSMAN.Management

WinRM-HTTP(S) Listener

Page 9: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

CIM

Teil von Web Based Enterprise Management

Microsoft: CIM Windows Management Instrumentation

PowerShell 3.0: WMI Cmdlets (DCOM)

Nur Windows

Nicht Firewall-freundlich

Ab PowerShell 4.0: CIM Cmdlets

Any-OS

Besseres Discovery, Abwärtskompatibel zu WIM, …

Page 10: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Managed Object Format

Beschreibung der Managementobjekte in CIM erfolgt

mittels MOF

MOF Dateien

Daten

Eventklassen

Page 11: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Voraussetzungen

Page 12: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

DSC einschalten

> WMF 4.0 beinhaltet DSC als OS-Feature

WinRM-HTTP(S) Listener und FW-Regel

Default-Image

Einschalten per Group Policy

Server-Installationsscript

Execution-Policy „Local and remote-signed“

Modul: PSDesiredStateconfiguration

Page 13: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Einführung in die Technologie

Page 14: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Einfache Architektur

Page 15: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Local Config Store

Detaillierter Aufbau

Language Extension

DSC CmdLets

DSC Resources

ConfigurationMOF

Local ConfigManager

Download Manager

File Download Manager

Web Download Manager

CurrentMOF

PreviousMOF

PendingMOF

SMB ShareConfiguration

MOF

Resources

Pull Service

ConfigurationMOF

Resources

IIS

PSW

S

DSC

Ser

vice

Pull Server/REST Staging

Authoring and Staging Configuration and Enacting

Page 16: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Ablauf

Erstellen und stagen:

Config-scripts schreiben

Configuration der Ziel-resourcen

Wie verteilen ?

Ausrollen/anwenden

Staging: Definiert wo die Konfiguration gespeichert wird

Push: Liefern der Konfig

Pull: Abholen der Konfig

Page 17: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

DSC PowerShell Module

Get-Command –Module

PSDesiredStateConfiguration

Script-Module zum konfigurieren von DSC

Beinhaltet BINARY Modul für LCM

Page 18: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

DSC Resourcen

Get-DSCResource

Identifiziert eine Einheit die mittels Konfigurationsscript

verwaltet werden kann.

Beispiele:

Eine Datei

OS-Rolle

Feature

Page 19: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

DSC Resourcen Online

PowerShell Gallery als Quelle

DSC ResourceKit Module sind markiert

Find-Module -Tag DSCResourcekit

Finde alle DCS Resourcen

Find-DSCResource

Installation: Install-Module –Name

„x“ Markierung: Experimenitell

„c“ Markierung: Community

Page 20: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Loslegen

Page 21: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Konfigurationsscript erzeugen

DEMO

Page 22: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

MOF Datei erzeugen

PS-Script ausführen

Erstellt Ordner

Erstellt MOF Datei

Page 23: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Staging und Auslieferung

MOF File ablegen:

Share

Versionskontrolle !

WebServer

Page 24: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Push & Pull Modi

Page 25: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Push Modus

Default-Modus zum Empfang von Konfigs

Ziel tut nichts aktiv (kein polling) für neue Konfig

Befehl: Start-DSCConfiguration

Problem Skalierbarkeit:

Limit simultaner CIM Sessions pro Computer

Problem komplexer Umgebungen

Wenn die DSC Ressource am Ziel nicht vorhanden ist

ERROR

Page 26: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Pull Modus

Erlaubt Verwaltung von Konfigurationen UND DSC

Ressourcen

Kann auf 2 Arten konfiguriert werden

SMB

OData WebService

Targets müssen mittels LCM auf „Pull-mode“ umgestellt

werden

MOF Files brauchen Checksummen

Page 27: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Pull über SMB

Einfach aufzubauen

\\Servername\Sharename

Rechtevergabe auf die Konfigurationsdateien

Page 28: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Pull über OData / HTTP

OData Endpoint mit „Windows PowerShell Desired State

Configuration Service“ installieren

Targets dann auf diesen OData Endpoint zeigen lassen.

Page 29: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Local Configuration Manager (LCM)

Page 30: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

LCM

CIM Klasse: MSFT_DscLocalConfigurationManager

DSC „Engine“

Läuft auf allen Systemen die > WMF 4.0 installiert haben

Nur verantwortlich für das Aktivieren der Konfiguration

Befehle:

Get-DscLocalConfigurationManager

Set-DscLocalConfigurationManager

Page 31: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Azure und DSC

Page 32: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Schema

Page 33: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Zusatzfeatures

Pull Server

Reporting Server

Automation Integration

DSC Res und Konfigs

als Assets

Page 34: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Zusammenfassung

Page 35: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Zusammenfassung

DSC für

Feature Installation/Konfiguration

Sicherheitsfunktionen erzwingen

Systemstabilität anheben (Services/Configuration drift))

Softwareverteilung

Standardisierung/Compliance

„Plattform“

Page 36: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Links

Page 37: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

Links

https://mva.microsoft.com/en-us/training-courses/getting-

started-with-powershell-desired-state-configuration-dsc--

8672

https://channel9.msdn.com/Series/Advanced-PowerShell-

Desired-State-Configuration-DSC-and-Custom-Resources

www.powershellmagazine.org

Page 38: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht

DSC Links

Microsoft:

Home: https://blogs.msdn.microsoft.com/powershell/

Azure and DSC: https://docs.microsoft.com/en-

us/azure/automation/automation-dsc-overview

GitHub Repo: https://github.com/PowerShell/DscResources

Blogs:

https://4sysops.com/archives/powershell-desired-state-

configuration-dsc-part-1-introduction/

Page 39: Einführung in Desired State Configuration › wp-content › uploads › ...Microsoft: CIM Windows Management Instrumentation PowerShell 3.0: WMI Cmdlets (DCOM) Nur Windows Nicht