SlideShare una empresa de Scribd logo
1 de 19
Chef 0.8, Knife & EC2
      The Bleeding Edge
Building Chef from Git


BTM’s GIST: chef 0.8 alpha installation

Git Clone & Build Gems ohai, mixlib-log,
mixlib-authentication, chef, chef-server,
chef-server-api, chef-server-webui, chef-
solar
Make a Baseline EC2
AMI with Chef Client
Set up Apt for multiverse, update, upgrade

Install fundamental packages and gems

   emacs, ruby, rubygems, ec2_tools, merb...

Install Chef Client related gems you built

Set up /etc/chef/client.rb

Clean up and run Eric Hammond’s ec2 build

AMI ends up in S3 and registered as an AMI
Generic client.rb
require 'ohai'
                                                        unless File.exists?("/etc/chef/client.pem")
require 'json'
                                                         File.open("/etc/chef/validation.pem", "w") do |f|
                                                           f.print(chef_config["validation_key"])
o = Ohai::System.new
                                                         end
o.all_plugins
                                                        end
chef_config = JSON.parse(o[:ec2][:userdata])
if chef_config.kind_of?(Array)
                                                        if chef_config.has_key?("attributes")
  chef_config = chef_config[o[:ec2][:ami_launch_index]]
                                                          File.open("/etc/chef/client-config.json", "w") do |f|
end
                                                            f.print(JSON.pretty_generate(chef_config["attributes"]))
                                                          end
log_level       :info
                                                          json_attribs "/etc/chef/client-config.json"
log_location     "/var/log/chef/client.rb"
                                                        end
chef_server_url chef_config["chef_server"]
registration_url chef_config["chef_server"]
                                                        validation_key "/etc/chef/validation.pem"
openid_url        chef_config["chef_server"]
                                                        validation_client_name
template_url      chef_config["chef_server"]
                                                        chef_config["validation_client_name"]
remotefile_url chef_config["chef_server"]
search_url        chef_config["chef_server"]
                                                        Mixlib::Log::Formatter.show_time = true
role_url        chef_config["chef_server"]
client_url      chef_config["chef_server"]

node_name        o[:ec2][:instance_id]
Instantiate a
         Chef Server
Instantiate the new chef-client AMI

Install Chef Server Gems (chef-server, chef-server-
api, chef-server-webui, chef-solar)

Use Chef Solo and danielsdeleo (Dan
DeLeo)’s bootstrap cookbook to setup Server

  Configures various /etc/chef files & certs

  Sets up runit to run the various servers

  Install couchdb
Startup the WebUI
Useful mainly for reality checking

Currently does not automatically set up the
WebUI

Have to manually start it on a port

Does not yet have an Apache/Passenger
frontend
sudo sh -c '/usr/bin/chef-server-webui -p 4002 > /
var/log/chef-server-webui.log' &
The Dev Process
Create/edit roles / cookbooks on dev machine

Use knife to upload to chef-server

Use knife to create user-data to pass to EC2
instantiate process to create customized
clients from your base chef client ami

Launch Instance

Debug
Hierarchy of Roles
We use a runa_base as a top level global
default configs

Then an environment role (staging, production,
etc) that “set”s the environment based overrides

Then a Function Role, like “dashboard” or
“runtime_db”

Still tend to need a recipe equivalent to allow
for aggregate attributes
Base Role
name "runa_base"                             Uses Json style
description "top level attributes"

recipes "users::env", "users::homes", "sudo", "emacs",
"git", "runa_base"

recipe
default_attributes(
  "runa" => {
    "home_base_dir"    => "/home",
    "mnt_point" => "/mnt",
    "bin_dir" => "/usr/local/bin",
    "upstart_event_dir" => "/etc/init",
    "summarizer" => {"namespaces" => ['lotus','tesla']},
    "target_user" => 'root',
    "target_group"=> 'root',
    "aws_access_key" => "secret",
    "aws_secret_access_key" => "secret",
    "availability_zone" => "us-west-1a"
  }
)
Staging Role
Find that I end up
using the recipe
attributes instead of
                         name "staging"
these since you can’t    description "staging environment"
refer to attributes in
                         recipes "staging"
other roles here
                         default_attributes({})

                         override_attributes ({})
Staging Recipes
     Here we can access
     the runa hash from
     the runa_base role


set[:runa_dashboard][:environment]     = "staging"
set[:runa_dashboard][:aws_access_key] = runa[:aws_access_key]
set[:runa_dashboard][:aws_secret_access_key] =
runa[:aws_secret_access_key]

set[:runa_dashboard][:availability_zone] = "us-west-1a"
Specific Function Role
     Mainly the recipes
     needed


name "runa_dashboard"
description "Use this role to make the node a runa_dashboard node"

recipes "runa_dashboard", "xfs", "aws", "mysql",
"runa_dashboard::ebs",
"mysql::server","runa_dashboard::configure_mysql",
"passenger_apache2", "runa_dashboard::setup",
"runa_dashboard::deploy"
Setting up Knife
Configure ~/.chef for personal config

~/.chef/knife.rb can be set up with editor or
a knife command

  log, connection info, path to cookbooks,

  Validation info for clients started by you

  Your credentials (Can use the chef-webui
  to start)
Knife Config File

log_level        :info
log_location     STDOUT
node_name        'rberger'
client_key       '/Users/rberger/.chef/rberger.pem'
chef_server_url 'http://chef-server-staging.runa.com:4000/'
cache_type       'BasicFile'
cache_options( :path => '/Users/rberger/.chef/checksums' )
cookbook_path [ '/Users/rberger/work/runa/runa_repo/
cookbooks', '/Users/rberger/work/runa/runa_repo/site-
cookbooks' ]
validation_client_name "validator"
Upload Roles and
Cookbooks with Knife
Upload Roles
  knife role from file ~/my_repo/roles/runa_base.rb


Upload Cookbooks all
  knife cookbook upload -a


Upload Individual Cookbook
  knife cookbook upload runa_dashboard
Validation Creds
Uploaded as part of user-data of starting ec2
instance

Used to authenticate the original connection between
a new chef client & chef-server

   After initial validation specific client creds are
   downloaded from chef-server

Having problems with this right now

Theoretically copy chef-server:/etc/chef/
validation.pem to your dev /etc/chef

Set the validator client name in ~/.chef/knife.rb
Starting a Specific
              Client on EC2
     Use Knife to generate user-data
        knife ec2 instance data “role[runa_base” 
        “role[staging]” “ role[runa_dashboard]”
{
  "attributes": {
     "run_list": [
       "role[runa_base]",
       "role[staging]",
       "role[runa_dashboard]"
     ]
  },
  "validation_key": "-----BEGIN RSA PRIVATE KEY-----
nMIIEowIBAAKCAQEAu9fKFLJz+JPSw5kWiRA6ywV1/omB73Juw9UyS/...
-----END CERTIFICATE-----n",
  "validation_client_name": "validator",
  "chef_server": "http://chef-server-staging.runa.com:4000/"
}
Start the EC2 instance
    with user-data
Can use command line ec2 tools or elastic
fox to start an instance of your chef client
AMI

Pass in the user data

Between Ohai and user-data is enough to
bootstrap the connection to chef-server

Gets Roles & Cookbooks and converges
Debugging
ssh to client

ps and syslog to see if basic chef-client start

Chef-client log for chef debug (like Ruby)

Run chef-client in standalone in debug mode

Can also see whats up on the chef-server in /etc/sv/
chef-server/log/main/current

Ask questions on #chef-hacking

Fix bugs back in dev, knife upload, run chef-client, rince,
repeat

Más contenido relacionado

La actualidad más candente

What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingJace Ju
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发shaokun
 
Masterclass Advanced Usage of the AWS CLI
Masterclass Advanced Usage of the AWS CLIMasterclass Advanced Usage of the AWS CLI
Masterclass Advanced Usage of the AWS CLIDanilo Poccia
 
(DEV301) Advanced Usage of the AWS CLI | AWS re:Invent 2014
(DEV301) Advanced Usage of the AWS CLI | AWS re:Invent 2014(DEV301) Advanced Usage of the AWS CLI | AWS re:Invent 2014
(DEV301) Advanced Usage of the AWS CLI | AWS re:Invent 2014Amazon Web Services
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
A re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbaiA re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbaiPraveen Puglia
 
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…D
 
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...D
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationJace Ju
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stackPaul Bearne
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsMichael Peacock
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with ExpressAaron Stannard
 
Chef on MongoDB and Pyramid
Chef on MongoDB and PyramidChef on MongoDB and Pyramid
Chef on MongoDB and PyramidRick Copeland
 
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014Amazon Web Services
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207patter
 
Getting up & running with zend framework
Getting up & running with zend frameworkGetting up & running with zend framework
Getting up & running with zend frameworkSaidur Rahman
 

La actualidad más candente (20)

What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstraping
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发
 
Masterclass Advanced Usage of the AWS CLI
Masterclass Advanced Usage of the AWS CLIMasterclass Advanced Usage of the AWS CLI
Masterclass Advanced Usage of the AWS CLI
 
(DEV301) Advanced Usage of the AWS CLI | AWS re:Invent 2014
(DEV301) Advanced Usage of the AWS CLI | AWS re:Invent 2014(DEV301) Advanced Usage of the AWS CLI | AWS re:Invent 2014
(DEV301) Advanced Usage of the AWS CLI | AWS re:Invent 2014
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
A re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbaiA re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbai
 
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
 
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
 
fabfile.py
fabfile.pyfabfile.py
fabfile.py
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stack
 
Phinx talk
Phinx talkPhinx talk
Phinx talk
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
 
Chef on MongoDB and Pyramid
Chef on MongoDB and PyramidChef on MongoDB and Pyramid
Chef on MongoDB and Pyramid
 
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Getting up & running with zend framework
Getting up & running with zend frameworkGetting up & running with zend framework
Getting up & running with zend framework
 
Getting up and running with Zend Framework
Getting up and running with Zend FrameworkGetting up and running with Zend Framework
Getting up and running with Zend Framework
 

Similar a BTM's GIST: Getting started with Chef 0.8 on EC2

Chef or how to make computers do the work for us
Chef or how to make computers do the work for usChef or how to make computers do the work for us
Chef or how to make computers do the work for ussickill
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppSmartLogic
 
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013Amazon Web Services
 
Using Test Kitchen for testing Chef cookbooks
Using Test Kitchen for testing Chef cookbooksUsing Test Kitchen for testing Chef cookbooks
Using Test Kitchen for testing Chef cookbooksTimur Batyrshin
 
Chef 0.10 Overview
Chef 0.10 OverviewChef 0.10 Overview
Chef 0.10 OverviewMatt Ray
 
Cookbook refactoring & abstracting logic to Ruby(gems)
Cookbook refactoring & abstracting logic to Ruby(gems)Cookbook refactoring & abstracting logic to Ruby(gems)
Cookbook refactoring & abstracting logic to Ruby(gems)Chef Software, Inc.
 
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Amazon Web Services
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.INRajesh Hegde
 
Kickstarter - Chef Opswork
Kickstarter - Chef OpsworkKickstarter - Chef Opswork
Kickstarter - Chef OpsworkHamza Waqas
 
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerGeorge Miranda
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!Jeff Anderson
 

Similar a BTM's GIST: Getting started with Chef 0.8 on EC2 (20)

Chef or how to make computers do the work for us
Chef or how to make computers do the work for usChef or how to make computers do the work for us
Chef or how to make computers do the work for us
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
AWS OpsWorks Under the Hood (DMG304) | AWS re:Invent 2013
 
Chef training - Day2
Chef training - Day2Chef training - Day2
Chef training - Day2
 
Using Test Kitchen for testing Chef cookbooks
Using Test Kitchen for testing Chef cookbooksUsing Test Kitchen for testing Chef cookbooks
Using Test Kitchen for testing Chef cookbooks
 
Chef 0.10 Overview
Chef 0.10 OverviewChef 0.10 Overview
Chef 0.10 Overview
 
Chef solo the beginning
Chef solo the beginning Chef solo the beginning
Chef solo the beginning
 
Cookbook refactoring & abstracting logic to Ruby(gems)
Cookbook refactoring & abstracting logic to Ruby(gems)Cookbook refactoring & abstracting logic to Ruby(gems)
Cookbook refactoring & abstracting logic to Ruby(gems)
 
Chef introduction
Chef introductionChef introduction
Chef introduction
 
Configuration management with Chef
Configuration management with ChefConfiguration management with Chef
Configuration management with Chef
 
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Cook Infrastructure with chef -- Justeat.IN
Cook Infrastructure with chef  -- Justeat.INCook Infrastructure with chef  -- Justeat.IN
Cook Infrastructure with chef -- Justeat.IN
 
Kickstarter - Chef Opswork
Kickstarter - Chef OpsworkKickstarter - Chef Opswork
Kickstarter - Chef Opswork
 
Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and Packer
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!
 

Más de Robert Berger

Scaling Runa Inc Big Data e-commerce service with AWS
Scaling Runa Inc Big Data e-commerce service with AWSScaling Runa Inc Big Data e-commerce service with AWS
Scaling Runa Inc Big Data e-commerce service with AWSRobert Berger
 
Personal Object Technology
Personal Object TechnologyPersonal Object Technology
Personal Object TechnologyRobert Berger
 
Facilitating Distributed Last Mile Broadband Access Providers
Facilitating Distributed Last Mile Broadband Access ProvidersFacilitating Distributed Last Mile Broadband Access Providers
Facilitating Distributed Last Mile Broadband Access ProvidersRobert Berger
 
The Linux Probability Wave
The Linux Probability WaveThe Linux Probability Wave
The Linux Probability WaveRobert Berger
 
802.11: Ethernet Marches On
802.11: Ethernet Marches On802.11: Ethernet Marches On
802.11: Ethernet Marches OnRobert Berger
 
Wireless commonsense fontsfixed
Wireless commonsense fontsfixedWireless commonsense fontsfixed
Wireless commonsense fontsfixedRobert Berger
 
Orchestrating HBase Cluster Deployment with Ironfan and Chef
Orchestrating HBase Cluster Deployment with Ironfan and ChefOrchestrating HBase Cluster Deployment with Ironfan and Chef
Orchestrating HBase Cluster Deployment with Ironfan and ChefRobert Berger
 
Deploying infrastructure with Opscode Chef
Deploying infrastructure with Opscode ChefDeploying infrastructure with Opscode Chef
Deploying infrastructure with Opscode ChefRobert Berger
 

Más de Robert Berger (9)

Scaling Runa Inc Big Data e-commerce service with AWS
Scaling Runa Inc Big Data e-commerce service with AWSScaling Runa Inc Big Data e-commerce service with AWS
Scaling Runa Inc Big Data e-commerce service with AWS
 
Personal Object Technology
Personal Object TechnologyPersonal Object Technology
Personal Object Technology
 
Facilitating Distributed Last Mile Broadband Access Providers
Facilitating Distributed Last Mile Broadband Access ProvidersFacilitating Distributed Last Mile Broadband Access Providers
Facilitating Distributed Last Mile Broadband Access Providers
 
The Linux Probability Wave
The Linux Probability WaveThe Linux Probability Wave
The Linux Probability Wave
 
802.11: Ethernet Marches On
802.11: Ethernet Marches On802.11: Ethernet Marches On
802.11: Ethernet Marches On
 
Open spectrum
Open spectrumOpen spectrum
Open spectrum
 
Wireless commonsense fontsfixed
Wireless commonsense fontsfixedWireless commonsense fontsfixed
Wireless commonsense fontsfixed
 
Orchestrating HBase Cluster Deployment with Ironfan and Chef
Orchestrating HBase Cluster Deployment with Ironfan and ChefOrchestrating HBase Cluster Deployment with Ironfan and Chef
Orchestrating HBase Cluster Deployment with Ironfan and Chef
 
Deploying infrastructure with Opscode Chef
Deploying infrastructure with Opscode ChefDeploying infrastructure with Opscode Chef
Deploying infrastructure with Opscode Chef
 

Último

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Último (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

BTM's GIST: Getting started with Chef 0.8 on EC2

  • 1. Chef 0.8, Knife & EC2 The Bleeding Edge
  • 2. Building Chef from Git BTM’s GIST: chef 0.8 alpha installation Git Clone & Build Gems ohai, mixlib-log, mixlib-authentication, chef, chef-server, chef-server-api, chef-server-webui, chef- solar
  • 3. Make a Baseline EC2 AMI with Chef Client Set up Apt for multiverse, update, upgrade Install fundamental packages and gems emacs, ruby, rubygems, ec2_tools, merb... Install Chef Client related gems you built Set up /etc/chef/client.rb Clean up and run Eric Hammond’s ec2 build AMI ends up in S3 and registered as an AMI
  • 4. Generic client.rb require 'ohai' unless File.exists?("/etc/chef/client.pem") require 'json' File.open("/etc/chef/validation.pem", "w") do |f| f.print(chef_config["validation_key"]) o = Ohai::System.new end o.all_plugins end chef_config = JSON.parse(o[:ec2][:userdata]) if chef_config.kind_of?(Array) if chef_config.has_key?("attributes") chef_config = chef_config[o[:ec2][:ami_launch_index]] File.open("/etc/chef/client-config.json", "w") do |f| end f.print(JSON.pretty_generate(chef_config["attributes"])) end log_level :info json_attribs "/etc/chef/client-config.json" log_location "/var/log/chef/client.rb" end chef_server_url chef_config["chef_server"] registration_url chef_config["chef_server"] validation_key "/etc/chef/validation.pem" openid_url chef_config["chef_server"] validation_client_name template_url chef_config["chef_server"] chef_config["validation_client_name"] remotefile_url chef_config["chef_server"] search_url chef_config["chef_server"] Mixlib::Log::Formatter.show_time = true role_url chef_config["chef_server"] client_url chef_config["chef_server"] node_name o[:ec2][:instance_id]
  • 5. Instantiate a Chef Server Instantiate the new chef-client AMI Install Chef Server Gems (chef-server, chef-server- api, chef-server-webui, chef-solar) Use Chef Solo and danielsdeleo (Dan DeLeo)’s bootstrap cookbook to setup Server Configures various /etc/chef files & certs Sets up runit to run the various servers Install couchdb
  • 6. Startup the WebUI Useful mainly for reality checking Currently does not automatically set up the WebUI Have to manually start it on a port Does not yet have an Apache/Passenger frontend sudo sh -c '/usr/bin/chef-server-webui -p 4002 > / var/log/chef-server-webui.log' &
  • 7. The Dev Process Create/edit roles / cookbooks on dev machine Use knife to upload to chef-server Use knife to create user-data to pass to EC2 instantiate process to create customized clients from your base chef client ami Launch Instance Debug
  • 8. Hierarchy of Roles We use a runa_base as a top level global default configs Then an environment role (staging, production, etc) that “set”s the environment based overrides Then a Function Role, like “dashboard” or “runtime_db” Still tend to need a recipe equivalent to allow for aggregate attributes
  • 9. Base Role name "runa_base" Uses Json style description "top level attributes" recipes "users::env", "users::homes", "sudo", "emacs", "git", "runa_base" recipe default_attributes( "runa" => { "home_base_dir" => "/home", "mnt_point" => "/mnt", "bin_dir" => "/usr/local/bin", "upstart_event_dir" => "/etc/init", "summarizer" => {"namespaces" => ['lotus','tesla']}, "target_user" => 'root', "target_group"=> 'root', "aws_access_key" => "secret", "aws_secret_access_key" => "secret", "availability_zone" => "us-west-1a" } )
  • 10. Staging Role Find that I end up using the recipe attributes instead of name "staging" these since you can’t description "staging environment" refer to attributes in recipes "staging" other roles here default_attributes({}) override_attributes ({})
  • 11. Staging Recipes Here we can access the runa hash from the runa_base role set[:runa_dashboard][:environment] = "staging" set[:runa_dashboard][:aws_access_key] = runa[:aws_access_key] set[:runa_dashboard][:aws_secret_access_key] = runa[:aws_secret_access_key] set[:runa_dashboard][:availability_zone] = "us-west-1a"
  • 12. Specific Function Role Mainly the recipes needed name "runa_dashboard" description "Use this role to make the node a runa_dashboard node" recipes "runa_dashboard", "xfs", "aws", "mysql", "runa_dashboard::ebs", "mysql::server","runa_dashboard::configure_mysql", "passenger_apache2", "runa_dashboard::setup", "runa_dashboard::deploy"
  • 13. Setting up Knife Configure ~/.chef for personal config ~/.chef/knife.rb can be set up with editor or a knife command log, connection info, path to cookbooks, Validation info for clients started by you Your credentials (Can use the chef-webui to start)
  • 14. Knife Config File log_level :info log_location STDOUT node_name 'rberger' client_key '/Users/rberger/.chef/rberger.pem' chef_server_url 'http://chef-server-staging.runa.com:4000/' cache_type 'BasicFile' cache_options( :path => '/Users/rberger/.chef/checksums' ) cookbook_path [ '/Users/rberger/work/runa/runa_repo/ cookbooks', '/Users/rberger/work/runa/runa_repo/site- cookbooks' ] validation_client_name "validator"
  • 15. Upload Roles and Cookbooks with Knife Upload Roles knife role from file ~/my_repo/roles/runa_base.rb Upload Cookbooks all knife cookbook upload -a Upload Individual Cookbook knife cookbook upload runa_dashboard
  • 16. Validation Creds Uploaded as part of user-data of starting ec2 instance Used to authenticate the original connection between a new chef client & chef-server After initial validation specific client creds are downloaded from chef-server Having problems with this right now Theoretically copy chef-server:/etc/chef/ validation.pem to your dev /etc/chef Set the validator client name in ~/.chef/knife.rb
  • 17. Starting a Specific Client on EC2 Use Knife to generate user-data knife ec2 instance data “role[runa_base” “role[staging]” “ role[runa_dashboard]” { "attributes": { "run_list": [ "role[runa_base]", "role[staging]", "role[runa_dashboard]" ] }, "validation_key": "-----BEGIN RSA PRIVATE KEY----- nMIIEowIBAAKCAQEAu9fKFLJz+JPSw5kWiRA6ywV1/omB73Juw9UyS/... -----END CERTIFICATE-----n", "validation_client_name": "validator", "chef_server": "http://chef-server-staging.runa.com:4000/" }
  • 18. Start the EC2 instance with user-data Can use command line ec2 tools or elastic fox to start an instance of your chef client AMI Pass in the user data Between Ohai and user-data is enough to bootstrap the connection to chef-server Gets Roles & Cookbooks and converges
  • 19. Debugging ssh to client ps and syslog to see if basic chef-client start Chef-client log for chef debug (like Ruby) Run chef-client in standalone in debug mode Can also see whats up on the chef-server in /etc/sv/ chef-server/log/main/current Ask questions on #chef-hacking Fix bugs back in dev, knife upload, run chef-client, rince, repeat