Download - Cooking on Windows without the Windows Cookbook

Transcript
Page 1: Cooking on Windows without the Windows Cookbook
Page 2: Cooking on Windows without the Windows Cookbook

Cooking Without the Windows Cookbook Adam Edwards [email protected] @adamedx

Software Engineer Opscode, Inc.

Page 3: Cooking on Windows without the Windows Cookbook

How to use Chef on Unix…

•  First, set up your knife workstation

•  Upload the Unix cookbook

•  Write some Unix recipes…

•  knife  cookbook  upload them

•  Edit your run list

•  Converge!

•  Upload the “Unix cookbook?”

•  HAHAHAHAHAHA

•  But there is a Windows cookbook...

Page 4: Cooking on Windows without the Windows Cookbook

So what’s this Windows cookbook?

•  A cookbook can add resources that aren’t supported by chef-client alone

•  Easy way to add early support for the Windows platform

•  Lots of goodies that make managing Windows possible:

•  windows_batch

•  windows_registry

•  windows_package

•  windows_task

•  windows_reboot

•  So much more – cool stuff!

•  It gives you power!

Page 5: Cooking on Windows without the Windows Cookbook

But I have to take it everywhere…

•  Seems like I’m always tossing ‘windows’ into metadata.rb

•  Even for the simplest recipes

•  If I’m on Windows, can’t Chef just “know” that I’m using the Windows cookbook?

•  The other chefs can do the basics with no cookbooks… •  Package, script / bash, many others all there on Unix

•  Oh, and there’s a separate PowerShell cookbook you need, too •  You do use PowerShell, right?

•  PSST, it’s better than bash J

Page 6: Cooking on Windows without the Windows Cookbook

Welcome to the kids table…

Page 7: Cooking on Windows without the Windows Cookbook

Oh and it infects Unix admins too

•  For Unix, admins can reuse popular cookbooks that support Windows

•  And those cookbooks often require the Windows cookbook

•  So now those Unix admins need the Windows cookbook •  Limits dependences we add to Windows cookbook

•  Case in point: git cookbook •  https://github.com/opscode-cookbooks/git/blob/master/metadata.rb

on your

Page 8: Cooking on Windows without the Windows Cookbook

OK, I’m convinced, no more Windows cookbook!

•  Let’s get rid of it!

•  Well, maybe not, after all, there is an Ubuntu cookbook…

•  Hey, put all the common goodies in chef-client!

•  Registry, batch, powershell, package, etc.

•  And while we’re at it, let’s make some improvements!

•  And also add lots of spec tests!

•  Then we spice up Windows cookbooks with power tools •  Not necessities

•  Now you can write more Windows recipes without Windows cookbook

•  Common tasks on Windows get easy!

Page 9: Cooking on Windows without the Windows Cookbook

Introducing a few new resources / features

•  Chef 11 adds new resources to chef-client •  registry_key, released in 11.0

•  powershell, in master, release pending

•  batch, in master, release pending

•  They support explicit control of 32-bit / 64-bit functionality

•  More on that later

•  Replaces analogs in Windows cookbook

•  And chef-client as a Windows service also in Chef 11 master

•  Can be configured at chef-client MSI installation time

•  So you don’t have to use chef-client cookbook

•  It’s also more robust, lightweight

Page 10: Cooking on Windows without the Windows Cookbook

A word on 32 / 64-bit

•  The new resources include an “architecture” attribute •  :i386 for x86, :x86_64 for x64

•  Defaults to :x86_64 on x64 Windows, :i386 otherwise

•  Wow64 (32-bit on 64-bit) is very confusing

•  You must be running in a 64-bit process to see 64-bit things •  Same for 32-bit processes

•  Windows cookbook resources can’t see 32-bit only registry

•  Causes weird, inexplicable anomalies •  Need weird hacks, workarounds not always feasible

•  But new resources let you control this, no more unpredictability! •  Our Unix friends just won’t understand J

Wow6432Node, SysWow64 WAT???!!!

Page 11: Cooking on Windows without the Windows Cookbook

registry_key

•  Usage is significantly different than the windows_registry resource

•  Values are modeled explicitly in addition to keys

•  So not a drop-in replacement, but more robust as a result

•  registry_key  "HKLM\\Software\\MyApp\\MyConfig"  do        values  [{          :name  =>  "NewRegistryKeyValue",          :type  =>  :multi_string,            :data  =>  foo\0bar\0\0      }]      architecture  :i386      action  :create    end  

•  You can control 32/64-bit!

Page 12: Cooking on Windows without the Windows Cookbook

powershell / batch

•  Analogs to powershell, windows_batch

•  Essentially drop-in replacements

•  Just change resource names, remove cookbook dependencies

•  batch  "batch_x86"  do      architecture  :i386      code  <<-­‐EOH      echo  I  am  an  %PROCESSOR_ARCHITECTURE%  script.  >  c:\\arch.txt      EOH  end  

•  powershell  “powershell_x64"  do      architecture  :x86_64      code  <<-­‐EOH      cd  wsman:\localhost\shell;  si  MaxMemoryPerShellMB  8192      EOH  end  

Page 13: Cooking on Windows without the Windows Cookbook

Demo: Registry, Powershell – No cookbooks

Page 14: Cooking on Windows without the Windows Cookbook

More Windows resources to come

•  Move remaining common resources to chef-client

•  Package

•  May unify ServerManager (aka windows_feature), DISM

•  Scheduled Tasks

•  Steroid enhanced cron

•  Reboot

•  More core resources => we can remove Windows dependency from git, other cookbooks

Page 15: Cooking on Windows without the Windows Cookbook

Bonus: Chef-Client as a (lightweight!) Windows service

•  Chef-client in master ships with chef-service-manager

•  Run chef-­‐service-­‐manager  -­‐a  to install chef-client as a Windows service

•  Or just install it via the MSI (graphical or msiexec) •  Obviates need to use chef-client cookbook

•  Updated implementation eliminates polling / busy wait •  Just sleeps until a timer event, no cpu, memory pages out

•  Shuts down via alertable thread

Page 16: Cooking on Windows without the Windows Cookbook

Demo – chef-client service

Page 17: Cooking on Windows without the Windows Cookbook

Not just more features, more Windows contributors!

•  Opscode is investing in Windows •  Engineers Seth Chisamore, John Keiser, others added Windows support, 2011, Q1 2012

•  H2 2012: More Opscode developers joined the fun:

•  Lamont Granquist

•  Prajakta Purohit

•  Serdar Sutay

•  Adam Edwards

•  Not just staffing, but sharing Windows across the engineering teams

•  Community is investing in Windows •  Contributions increasing as we gain Windows users

•  Example: See the Nordstrom Unicorns about Mixlib::Shellout, Printer LWRP, chef-vault…

•  Doug Ireton, Kevin Moser, more…

Page 18: Cooking on Windows without the Windows Cookbook

Beyond cookbooks – more Chef for Windows!

•  We are not done – more good things coming to Chef on Windows!

•  What if the chef-client msi made knife workstation experience better?

•  What if I had an actual editor on my knife workstation?

•  Maybe even a better terminal (ConEmu anyone?)

•  Can we take more advantage of Windows coolness? •  Can knife and PowerShell work better together?

•  64-bit (Ruby 2.0) Chef-client?

•  Let your voice be heard – http://community.opscode.com

•  Happy 10th Anniversary Windows Server 2003 and x64 Windows! •  Launched April 24, 2003, San Francisco, CA

Windows CAN because CODE CAN

Page 19: Cooking on Windows without the Windows Cookbook