+ All Categories
Home > Documents > Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Date post: 21-Jul-2016
Category:
Upload: victor-v-evans
View: 215 times
Download: 1 times
Share this document with a friend
29
Webinar: Cooking with Chef on Microsoft Windows Julian C. Dunn Senior Consultant, Opscode, Inc. <[email protected]>
Transcript
Page 1: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Webinar:Cooking with Chef on Microsoft WindowsJulian C. Dunn

Senior Consultant, Opscode, Inc.

<[email protected]>

Page 2: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Introduction to Opscode and Chef

Page 3: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

•New model for describing infrastructure that promotes reuse

•Programmatically provision and configure

•Reconstruct business from code repository, data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“ ”

Page 4: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Chef and Windows Support Milestones

•May 2011 – Knife plugin for Windows announced

•Oct 2011 – PowerShell, IIS, SQL Server, and Windows cookbooks

•Dec 2011 – Chef Client Installer MSI for Microsoft Windows

•Feb 2012 – Integration of the registry_key resource into core Chef from the Windows cookbook

•Aug 2013 – Chef 11.6.0 release. PowerShell and Batch scripting integrated into core Chef. Chef Client released as Windows service

•Aug 2013 - PowerShell Desired State Configuration support announced (for delivery later in 2013)

Page 5: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Notable Chef Customers on Windows

Page 6: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Automating a .NET App on Windows

Page 7: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Automating a .NET App on Windows

• The app: nopCommerce Shopping Cart solution (www.nopcommerce.com)

• ASP.NET with SQL Server backend

• Available through WebPI

• WebPI install assumes a lot, however

• Full-featured app suitable to show off Chef resources on Windows

Page 8: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Resources Automated in this Demo

• Installing Windows Features and Roles

• IIS app pool

• IIS site

• IIS app

• Registry settings

• Deploying files onto the system

• Unzipping files 

• Windows filesystem rights management

Page 9: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Provisioning with Chef

• Beta of the Azure plugin for Chef

• Request new VM from Azure API

• Bootstrap it over WinRM

• Install and start Chef

• Register with Chef server

• Run through the “run list”

• Instant infrastructure with one command

Page 10: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Video

Page 11: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

The Recipe Code

Page 12: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

nopCommerce Recipe Code: Install IIS, ASP.NET 4.5

Page 13: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

nopCommerce Recipe Code: Install nopCommerce

Page 14: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

nopCommerce Recipe Code: Set up IIS Site, App Pool, App

Page 15: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Other Recipe Code You Might Have Noticed

cookbook_file 'C:\Windows\System32\oemlogo.bmp' do source node['windowshacks']['oeminfo']['logofile'] rights :read, "Everyone" action :createend

registry_key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation' do values [{:name => 'Logo', :type => :string, :data => 'C:\Windows\System32\oemlogo.bmp'}, {:name => 'Manufacturer', :type => :string, :data => node['windowshacks']['oeminfo']['manufacturer']}, {:name => 'SupportHours', :type => :string, :data => node['windowshacks']['oeminfo']['supporthours']}, {:name => 'SupportPhone', :type => :string, :data => node['windowshacks']['oeminfo']['supportphone']}, {:name => 'SupportURL', :type => :string, :data => node['windowshacks']['oeminfo']['supporturl']}] action :createend

Page 16: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

The Result

Page 17: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Overview of Chef Resources on Windows

Page 18: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Chef Resources on Windows: Same as UNIX/Linux

• file, remote_file, cookbook_file, template

• directory, remote_directory

• user, group

• mount (can take CIFS paths)

• env

• service

• execute

• ruby_block

• many others...Photo Credit: L. Allen Brewer

Page 19: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Windows-Only Resources

• registry_key (new in Chef 11.0.0)

• powershell_script (new in Chef 11.6.0)

• batch (new in Chef 11.6.0)

• Automatic architecture handling (:i386 vs. :x86_64)

• Automatic Windows filesystem redirector handling (Wow64)

• Long-term roadmap: move more resources to core and out of ‘windows’ cookbook

Page 20: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Windows-Only Cookbooks

• By Opscode:

• 7-zip

• iis

• powershell

• sql_server

• webpi

• windows

• wix

• Many others in the community

• couchbase

• ms_dotnet45

• (to name but a few) Photo Credit: Marc Falardeau

Page 21: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

registry_key example

# Set system’s proxy settings to be the same as used for Chef

proxy = URI.parse(Chef::Config[:http_proxy])

registry_key 'HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings' do

values [{:name => 'ProxyEnable', :type => :reg_dword, :data => 1},

{:name => 'ProxyServer', :data => "#{proxy.host}:#{proxy.port}"},

{:name => 'ProxyOverride', :type => :reg_string, :data => '<local>'}]

action :create

end

Page 22: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

powershell_script example

powershell_script "rename hostname" do

code <<-EOH

$computer_name = Get-Content env:computername

$new_name = 'test-hostname'

$sysInfo = Get-WmiObject -Class Win32_ComputerSystem

$sysInfo.Rename($new_name)

EOH

end

Page 23: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Registry Idempotency Helpers

• Resources like powershell_script are not idempotent by default

• We provide some helpers for checking the registry:

• registry_data_exists?

• registry_get_subkeys

• registry_get_values

• registry_has_subkeys?

• registry_key_exists?

• registry_value_exists?

Page 24: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Special File and Directory Permissions Handling on Windows

• Parameters that don’t make sense are ignored

• DOMAIN\user, DOMAIN\group work

• Filesystem ACLs are different on Windows

• mode parameter semantics

• rights parameter only for Windows

Page 25: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

The “windows” cookbook

• The windows cookbook includes a number of resources and providers, and helper libraries.

• See https://github.com/opscode-cookbooks/windows for a full list

• Highlights:

• windows_auto_run

• windows_feature

• windows_package

• windows_path

• windows_reboot

• windows_zipfile

• Other: windows_printer, windows_printer_port, windows_task

Photo Credit: peyri

Page 26: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Helper Functions in Windows Cookbook

• Libraries (include Windows::Helper):

• win_friendly_path - ensures backslashes are used everywhere

• win_version:

• server_core? server_full? server_datacenter?

• windows_7? windows_server_2008_r2? etc.

Photo Credit: ilovecocacola

Page 27: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Windows Report Handlers

• Windows cookbook:

• WindowsRebootHandler

• windows_reboot resource

• windows::reboot_handler recipe

• Eventlog cookbook:

• Send Chef output to Windows Event Log

Photo Credit: blakespot

Page 28: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Wrap Up / Q&A

Page 29: Cookingwithchefonwindowswebinar8!27!2013 130827174038 Phpapp02

Wrap-Up and Q&A

• Much more than what’s shown here!

• Blog posts and other webinars to come

• Questions?

Thank you!

E: [email protected]

W: www.opscode.com/blog

T: @julian_dunn

G: github.com/juliandunn


Recommended