Post on 15-Aug-2015
Learn how to start cooking with Chef!Fredrik NilssonPrincipal Consultant - InfrastructureCrayon – The Software Experts
Fredrik NilssonPrincipal Consultant - InfrastructureCrayon
Email: Fredrik.Nilsson@Crayon.com
Blog: moln1.wordpress.com
Twitter: @FredrikNilsson_
Bork! Bork! Bork!
Sweden
Cooking
+
Terms used in ChefKnife: Command line tool to manage infrastructure and bootstrap chef.
Resource:Fundamental building block, a piece of the system and it’s desired state
Recipe:A recipe is a collection of resources
Cookbook : Collection of recipes for managing the resource
Runlist: A policy which needs to be applied on the node
Click icon to add picture
Chef OverviewChef ServerCentral store for Cookbooks and Policy settingsChef management console
Node(s)A chef-client is installed on every node that is under management by ChefPulls data from the Chef Server
WorkstationDeveloping cookbooks and recipesKnife CMD line tool
AnalyticsRealtime visabilityVerify Compliance
Getting startedMicrosoft Virtual Academy - Managing Your Systems on Microsoft Azure with Chef http://www.microsoftvirtualacademy.com/training-courses/managing-your-systems-on-microsoft-azure-with-chef
Learn Chefhttps://learn.chef.io/
Create a folder structure # Create Directories for Chef WorkstationNew-Item -ItemType directory -Path C:\Chef\Cookbooks
Microsoft Azure Publish Settings
https://manage.windowsazure.com/publishsettings/
• Open the file in your editor of choice and modify the /../ from the “cookbook_path”
cookbook_path ["#{current_dir}/cookbooks"] knife[:azure_publish_settings_file] = "yourfilename.publishsettings”
Add the line knife[:azure_publish_settings_file] = "yourfilename.publishsettings”
Edit Knife.rbKnife-Azure
Knife.rb# See https://docs.chef.io/config_rb_knife.html for more information on knife
configuration optionscurrent_dir = File.dirname(__FILE__)log_level :infolog_location STDOUTnode_name "czw2pv“client_key "#{current_dir}/czw2pv.pem“validation_client_name "ignitedemo-validator“validation_key "#{current_dir}/ignitedemo-validator.pem“chef_server_url https://api.opscode.com/organizations/ignitedemocookbook_path ["#{current_dir}/cookbooks"]knife[:azure_publish_settings_file] = "Visual Studio Premium with MSDN-4-22-2015-credentials.publishsettings"
• Confirm that these three variables1. C:\opscode\chefdk\bin;2. C:\opscode\chefdk\embedded\bin;3. C:\users\yourusername\.chefdk\gem\ruby\2.1.0\bin
NOTE THE ORDER OF THE PATH IS IMPORTANTC:\opscode\chefdk\bin;C:\opscode\chefdk\embedded\bin;C:\users\yourusername\.chefdk\gem\ruby\2.1.0\bin
Verify System Environment VariablePath
Powershell# Install Knife-Azurechef gem install knife-azure
# List avalible image listknife azure image list
# Creating a Cookbookchef generate cookbook webserver
default.rbpowershell_script 'Install IIS' do action :run code 'add-windowsfeature Web-Server' end service 'w3svc' do action [ :enable, :start ] end template 'c:\inetpub\wwwroot\Default.htm' do source 'Default.htm.erb‘ rights :read, 'Everyone' end
Powershell# Creating a templatechef generate template webserver Default.htm
# Upload the Cookbook to the Chef Serverknife cookbook upload webserver
More Chef resourcesIgnite SessionsBRK3722 Managing Linux and Windows on Microsoft Azure with ChefThursday, May 7 9:00am - 10:15am
LinksChef + Microsoft Azure https://www.chef.io/solutions/azure/Using Chef to Manage Azure Resources https://msopentech.com/blog/2014/03/31/using-chef-to-manage-azure-resources/Microsoft Virtul Academy - Managing Your Systems on Microsoft Azure with Chef http://www.microsoftvirtualacademy.com/training-courses/managing-your-systems-on-microsoft-azure-with-chefMicrosoft Open technologieshttp://msopentech.comGit Hubhttps://github.com/chef/knife-azure