PowerShell DSC for Linux, Step by Step

We are privileged to have a guest blogger on Building Clouds, Kristopher Bash.  Kris is a Senior Program Manager in the Microsoft Open Source Technology Center.  Last week at TechEd, Jeffrey Snover was a surprise guest in Don Jones’ presentation, where he demonstrated applying a configuration to a Linux box using PowerShell DSC through standards based management technology, WS-Man.

Kris has authored a step by step guide on the subject and we are lucky to have him share his work via BCB!


Building and Installing DSC for Linux

We have just announced the initial availability of a CTP for Windows PowerShell Desired State Configuration for Linux! This initial release is delivered as open-source code, and in this post, I will provide a detailed walkthrough for building and installing the DSC LCM on a Linux computer and applying your first configuration.


Building OMI 1.0.8 requires the following packages:

  • pam-devel
  • openssl-devel


In this walkthrough, I will build and install OMI and DSC on a CentOS 6 Linux computer.

·         Firstly, I will install the required prerequisite packages to build OMI and the DSC components:

root@lab-dev-02  # yum groupinstall ‘Development Tools’

root@lab-dev-02  # yum install pam-devel

root@lab-dev-02  # yum install openssl-devel


·         Then, I can download and extract OMI 1.0.8 from The Open Group (https://collaboration.opengroup.org/omi/documents/30532/omi-1.0.8.tar.gz).  I’ll use /root/downloads as my working directory for OMI and DSC:

root@lab-dev-02  # mkdir /root/downloads

root@lab-dev-02  # cd /root/downloads

root@lab-dev-02  # wget https://collaboration.opengroup.org/omi/documents/30532/omi-1.0.8.tar.gz

root@lab-dev-02  # tar -xvf omi-1.0.8.tar.gz


·         Next, I’ll configure, build, and install OMI 1.0.8.  By default, this will install OMI to /opt/omi-1.0.8/

root@lab-dev-02  # cd omi-1.0.8/

root@lab-dev-02  # ./configure

created /root/downloads/omi-1.0.8/output

root@lab-dev-02  # make

root@lab-dev-02  # make install

Successfully installed under under: ///opt/omi-1.0.8


·         OMI 1.0.8 is now installed on my computer, and I can move on to installing the DSC components (Local Configuration Manager and Resource Providers).  I’ll install Python and download the DSC components:

root@lab-dev-02  # yum install python

root@lab-dev-02  # yum install python-devel

root@lab-dev-02  # cd /root/downloads

root@lab-dev-02  # wget https://github.com/MSFTOSSMgmt/WPSDSCLinux/releases/download/v1.0.0-CTP/PSDSCLinux.tar.gz

root@lab-dev-02  # tar -xvf PSDSCLinux.tar.gz
root@lab-dev-02  # mv ./dsc/* ./

root@lab-dev-02  # ls -l

total 7504

-r-xr-xr-x.  1 3482 3482      78 May 12 09:53 configure

drwxrwxr-x.  2 3482 3482    4096 May 12 09:53 Example DSCs

-rw-r–r–.  1 root root   11862 May 15 08:41 index.html

drwxrwxr-x.  5 3482 3482    4096 May 12 09:53 LCM

-r–r–r–.  1 3482 3482    9144 May 12 09:53 license.txt

-r–r–r–.  1 3482 3482     183 May 12 09:53 Makefile

drwxr-xr-x. 46 root root    4096 May 15 08:45 omi-1.0.8

-rw-r–r–.  1 root root 3623018 May 15 08:41 omi-1.0.8.tar.gz

drwxrwxr-x.  9 3482 3482    4096 May 12 09:57 Providers

-rw-r–r–.  1 root root 4003840 May 12 10:58 PSDSCLinux.tar

-r–r–r–.  1 3482 3482    3958 May 12 09:53 README.txt
root@lab-dev-02  # make

root@lab-dev-02  # make reg


Now, both OMI and the Desired State Configuration components (Local Configuration Manager and Resource Providers) are installed.

Running OMI and the LCM

·         The DSC installation performed in the previous steps registers the Local Configuration Manager as an OMI provider with OMI, so I simply need to run omiserver to enable DSC:

To run omiserver in an active tty (which is useful for debugging DSC):

root@lab-dev-02  # OMI_HOME=/opt/omi-1.0.8 /opt/omi-1.0.8/bin/omiserver


To run omiserver as a background process (daemon):

root@lab-dev-02  # OMI_HOME=/opt/omi-1.0.8 /opt/omi-1.0.8/bin/omiserver -d



·         For ongoing management of the Linux system, we clearly want omiserver to run as a service and start on boot of the Linux computer. For that, we’ll need to create an init script.   Here is an example init script:

#! /bin/sh


 # Provides:          omiserver

 # Required-Start:    $local_fs $remote_fs

 # Required-Stop:    $local_fs $remote_fs

 # Default-Start:     3 4 5

 # Default-Stop:      0 1 2 6

 # Short-Description: omiserver initscript

 # Description:      omiserver



 # Do NOT “set -e”



 export OMI_HOME=/opt/omi-1.0.8/







 # Define LSB log_* functions.

 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.

 . /lib/lsb/init-functions



 # Function that starts the daemon/service




         /opt/omi-1.0.8/bin/omiserver -d