18
PowerShell Desired State Configuration for Linux By: Kolby Allen August 19, 2015 LINUXCON North America

PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

Embed Size (px)

Citation preview

Page 1: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

PowerShell  Desired  State  Configuration  for  Linux

By:  Kolby  AllenAugust  19,  2015

LINUXCON  North  America

Page 2: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 2

Outline

-­‐ What  is  PowerShell  and  Desired  State  Configuration?-­‐ Why  would  I  use  PowerShell  for  Linux?-­‐ Review  of  Desired  State  Configuration

-­‐ Server  Setup-­‐ Client  Setup

-­‐ Examples-­‐ Webserver  Configuration-­‐ End  to  End  Provisioning  (Hyper-­‐V  to  Webserver)

-­‐ Q/A

Page 3: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 3

What  is  PowerShell?

-­‐ PowerShell  – task  automation  and  management  tool-­‐ Allow  for  both  local  and  remote  management-­‐ Scripting  language-­‐ V1  shipped  in  2006  as  optional-­‐ V2  shipped  with  Win7  and  Server  2008-­‐ V5  currently  in  preview  (unless  your  on  Win10?)

Reboot  Local  Machine:Restart-Computer

Reboot  Remote  Machine:Restart-Computer -ComputerName Server01

Reboot  Remote  Machines  (multiple):Restart-Computer -ComputerName Server01, Server02, localhost

Page 4: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 4

What  is  Desired  State  Configuration?

-­‐ PowerShell  Desired  State  Configuration  was  released  to  allow  for  deployment  and  management  of  configuration  data

-­‐ Follows  DMTF  management  standards  and  WS-­‐Management  Protocol

-­‐ Applications:-­‐ Server  role/feature  management-­‐ Setting/Changing  registry  items-­‐ Process/service  management-­‐ User/Group  Management-­‐ Software  Deployment  and  setup-­‐ Remote  script  execution-­‐ Managing  configuration  drift-­‐ Actual  configuration  reporting

Page 5: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 5

Why  use  DSC?

WHY  NOT  ONE  OF  THESE?

Page 6: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 6

Why  use  DSC?

Because  of  this…

Page 7: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 7

Review  of  DSC  – Server  Setup  -­‐ PUSH

Push  Server

Start-DscConfiguration

Local Target

Configurations

Local Configuration Manager (LCM)

Remote Machine

LCM

Remote Machine

LCM

configuration

configuration

http://blogs.msdn.com/b/powershell/archive/2013/11/26/push-­‐and-­‐pull-­‐configuration-­‐modes.aspx

Page 8: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 8

Review  of  DSC  – Server  Setup  -­‐ PUSH

http://blogs.msdn.com/b/powershell/archive/2013/11/26/push-­‐and-­‐pull-­‐configuration-­‐modes.aspx

Author Configuration

Generate MOF

PushConfiguration

Page 9: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

DSC OData Endpoint

IIS Service

Configurations

Remote Machine

LCM

Remote Machine

LCMResources

get

send

get

send

8/19/2015 PowerShell  DSC  for  Linux 9

Review  of  DSC  – Server  Setup  -­‐ PULL

Pull  Server

http://blogs.msdn.com/b/powershell/archive/2013/11/26/push-­‐and-­‐pull-­‐configuration-­‐modes.aspx

Page 10: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 10

Review  of  DSC  – Server  Setup  -­‐ PULL

http://blogs.msdn.com/b/powershell/archive/2013/11/26/push-­‐and-­‐pull-­‐configuration-­‐modes.aspx

Author Configuration

for TargetSetup Pull

ServerSetup DSCon target

Page 11: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 11

Review  of  DSC  – Client  Setup

Support  Operating  Systems• CentOS5,  6,  &  7• Debian GNU/Linux  6  &  7• Oracle  Linux  5,  6,  &  7• RHEL  5,  6,  &  7• SUSE  10,  11,  &  12• Ubuntu  12.04  LTS  &  14.04  LTS

Required  Packages:-­‐ glibc-­‐ python-­‐ omniserver -­‐ Open  Management  

Infrastructure-­‐ openssl-­‐ ctypes-­‐ libcurl

DSC  for  Linux  Binarieshttps://github.com/MSFTOSSMgmt/WPSDSCLinux

Page 12: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 12

Review  of  DSC  – Client  Setup  – LINUX  Resources

DSC  Resources  – building  blocks  to  DSC  ConfigurationsLinux  Resources

• nxFile – manages  files  and  directory  state• nxScript – run  script  blocks  on  target  nodes• nxUser – manages  linuxusers• nxGroup –manages  linuxgroups• nxService – manages  linux services  (System-­‐V,  upstart,  systemd)

Currently  in  beta  but  growing.

Page 13: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 13

DSC  Examples  – DSC  Configuration

Force  feature  to  be  installed

Servers  installed  on

Adds  file  to  OS

Page 14: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 14

DSC  Examples  – DSC  Configuration  – Windows  WebServer

Page 15: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 15

DSC  Examples  – Demo

DEMO

Page 16: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 16

DSC  Examples  – End  to  End  Provisioning

• Most  corporate  environments  use  Hyper-­‐V  or  VMWare• Hyper-­‐V  has  DSC  Resources  (form  MS)• VMWare  Powershell tools  (requires  custom  DSC  Resource)• Just  requires  that  you  have  built  a  VM  with  all  pre-­‐reqs

• Hyper-­‐V  and  PS  DSC  for  Linux  support  the  same  operating  services• Once  VM  is  deployed  you  can  use  DSC  push  server  to  do  initial  setup

Page 17: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 17

DSC  Examples  – End  to  End  Provisioning  – Hyper-­‐V

http://mikefrobbins.com/2015/01/22/creating-­‐hyper-­‐v-­‐vms-­‐with-­‐desired-­‐state-­‐configuration/

Page 18: PowerShell)Desired)State) Configuration)for)Linux · PowerShell)Desired)State) Configuration)for)Linux By: ... K PowerShell$Desired$State$Configuration$was$released$to$allow$for$

8/19/2015 PowerShell  DSC  for  Linux 18

Review  of  DSC  – Conclusion

• DSC  Provides  a  new  set  of  tools  for  machine  configuration• Allows  integration  with  current  Windows  SysAdmin toolset• Hyper-­‐V  and  VMWare  end  to  end  provision  capabilities• A  new  tool  to  manage  servers