learning powershell dsc - sample chapter

Download Learning PowerShell DSC - Sample Chapter

Post on 04-Dec-2015




2 download

Embed Size (px)


Chapter No. 5 Pushing DSC ConfigurationsGet started with the fundamentals of PowerShell DSC and utilize its power to automate deployment and configuration of your serversFor more information: http://bit.ly/1QRlZCe


  • P r o f e s s i o n a l E x p e r t i s e D i s t i l l e d

    Get started with the fundamentals of PowerShell DSC and utilize its power to automate the deployment and confi guration of your servers

    Learning PowerShell DSCJames P

    ogranLearning Pow

    erShell DSC

    Learning PowerShell DSC

    Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. PowerShell DSC is a new management platform that enables you to deploy and manage confi guration data for software services and manage the environment in which these services run.

    This book begins with an overview of the basics of PowerShell DSC by covering the architecture and components of the Desired Sate Confi guration. It will then familiarize you with the set of PowerShell language extensions and the new PowerShell commands. It will help you create DSC confi gurations with the help of practical examples and DSC custom resources for your custom applications. Finally, you will learn to deploy a real-world application using PowerShell DSC. By the end of the book, you will have better knowledge of the powerful DSC platform, which helps you achieve continuous delivery, and effi cient management and easy deployment of data for systems.

    Who this book is written forThis book is intended for system administrators or engineers who are responsible for confi guration management and automation and wish to learn PowerShell DSC for the effi cient management, confi guration, and deployment of systems and applications.

    $ 49.99 US 31.99 UK

    Prices do not include local sales tax or VAT where applicable

    James Pogran

    What you will learn from this book

    Understand confi guration management and why you need it

    Craft fl exible, reusable, and maintainable confi guration scripts for thousands of servers

    Create custom DSC Resources to manage any application or server setting

    Use confi guration data to deploy applications to different environments

    Utilize DSC push deployments to test your confi guration scripts and custom DSC Resources

    Install, confi gure, and use DSC Pull Servers

    Run a Windows MSI package

    Deploy a website

    P U B L I S H I N GP U B L I S H I N G

    professional expert ise dist i l led

    P U B L I S H I N GP U B L I S H I N G

    professional expert ise dist i l led

    Visit www.PacktPub.com for books, eBooks, code, downloads, and PacktLib.

    Free Sam


  • In this package, you will find: The author biography

    A preview chapter from the book, Chapter 5 'Pushing DSC Configurations' A synopsis of the books content

    More information on Learning PowerShell DSC

  • About the Author

    James Pogran has been working with computers in some form or fashion for over 15 years. His fi rst job was systems administration for a large military installation. He then moved on to develop monitoring software and automate large scale Windows environments for a major managed services provider. He is currently a software engineer at Puppet Labs where he helps to make Windows automation even better with Puppet.

  • PrefaceWindows PowerShell was a transformative event for the Windows management ecosystem. It marked a shift from the GUI-based administration of "click next, next, fi nish" to a composable command line experience that can be scripted and automated. This methodology was not accepted immediately by the Windows community, but time has proven the approach viable and PowerShell is now an integral part of any systems administrator's toolkit.

    Windows PowerShell Desired State Confi guration (DSC) marks another shift in Windows administration, but this time, it is a move away from the run-once scripts that cannot detect the existing state to declarative and repeatable automation without side effects. While PowerShell enabled an automation paradigm that was previously unmatched on Windows systems, crafting truly dependable automation took many lines of boilerplate code of exception catching and state checking. DSC handles this boilerplate code and gives you a clean and readable way to declare the expected state of your systems without worrying about how those systems are confi gured.

    Whether you manage a few servers or several thousands of them, the same problems occur repeatedly. How do you ensure that all the servers under your care are confi gured to the exact specifi cations? How do you write those specifi cations down so that not only you and your coworker but also the machine understands them? This seemingly confl icting set of requirements is the purpose of DSC. Using DSC, you can write the human-readable desired state of the system you expect, and DSC ensures that the state of the system is what you desired it to be.

  • Preface

    In this book, we will introduce the confi guration management concepts that DSC uses to accomplish these feats. We then cover the architecture of DSC, which allows us to specify the state of a target system without having to code the implementation details ourselves. From there, we will cover how to create fi les that can be read by both DSC and humans to ensure that the state of target systems is what we specify. We will then address how to customize DSC to administer our customized and unique environments, and then walk through the ways in which we can deploy these confi gurations to the target systems using the different deployment models of DSC. We will wrap up with a walkthrough of a typical deployment cycle of example software using real-world problems and solutions.

    What this book coversChapter 1, Introduction to PowerShell DSC, introduces you to PowerShell DSC and confi guration management concepts. It covers the features included in DSC and briefl y introduces the different DSC versions.

    Chapter 2, DSC Architecture, covers all three phases of DSC in depth, the two different DSC deployment models, and the considerations to be made when deploying a Pull Server or using a push deployment.

    Chapter 3, DSC Confi guration Files, covers authoring the DSC confi guration scripts and confi guration data fi les from end to end. It also covers how to use them together effectively.

    Chapter 4, DSC Resources, covers the DSC Resource syntax and fi le structure in both PowerShell v4 and v5. It shows how to fi nd DSC Resources on the local system as well as using community and Microsoft-provided online resources.

    Chapter 5, Pushing DSC Confi gurations, gives step-by-step instructions on how to push DSC confi gurations to remote target nodes. It also covers the extra steps the user must take to make push deployments work and discusses the pros and cons of using push deployments.

    Chapter 6, Pulling DSC Confi gurations, gives step-by-step instructions on how to set up a DSC Pull Server and your environment to best utilize a pull-based deployment. It covers the pros and cons of using pull deployments in comparison to push deployments.

    Chapter 7, Example Scenarios, covers the use of DSC in the real world and how to integrate DSC into not only new environments but also with legacy-style deployments. This chapter walks us through the thought processes of handling the changing requests and the requirements of different software deployments using DSC.

  • [ 153 ]

    Pushing DSC Confi gurationsWe have covered everything there is to know about DSC and its internals at this point, but we have not fully explained the different ways DSC confi gurations actually get to the target nodes. In the fi rst chapters of the book, we learned that there are two models to DSC: a push and a pull model. In this chapter, we will be covering the push model. We will fi rst defi ne what the push model is and then move on to how to use it with DSC confi gurations. We'll take an example confi guration and apply it to a local target node and a remote target node.

    In this chapter, we will cover the following topics:

    Tooling Setting things up Locally pushing DSC configurations Remotely pushing DSC configurations

    ToolingDSC supports applying DSC confi gurations locally and remotely using the Start-DscConfiguration Cmdlet. This Cmdlet handles both copying the MOF fi le to the target node and telling DSC to execute the MOF on the target node.

    Start-DscConfiguration can be invoked interactively as well as run in the background. Interactive executions are run as we are watching and are able to show us verbose output as each step in the DSC confi guration happens. Background executions are PowerShell jobs that do not block your shell, so that you can do other things while the job runs. This means you can use this Cmdlet to push a DSC confi guration and then walk away or continue to use your current PowerShell console session to do other things as it executes on the target node.

  • Pushing DSC Confi gurations

    [ 154 ]

    All output from the DSC confi guration execution is logged by DSC, and the Start-DscConfiguration Cmdlet can show this information, if confi gured. By default, it only displays error and completion information, but it can be confi gured to yield verbose output by using the Verbose parameter.

    It is important to note that Start-DscConfiguration does not perform the execution itself; the DSC service does this on the target node. This means nothing is tied to you, your shell, or your session. Your current console session could stop or go away and the execution would still run. This allows a "set it and forget it" workfl ow where you push a confi guration and walk away to do other things while it runs, and then come back and fi nd the results of the execution ready and waiting for you.

    Setting things upUp until now, you could have gotten away with just looking at the examples in the book withou


View more >