Reveal.js – HTML Presentations Made Easy – Vertical Slides



Reveal.js – HTML Presentations Made Easy – Vertical Slides

0 0


chef-solo-intro


On Github linc01n / chef-solo-intro

Chef Solo Introduction

Lincoln Lee

@linc01n

http://chef-solo-intro.lincoln.hk

10 July 2013

What is Chef?

  • Cloud Infrastructure Automation Framework

  • Infrastructure as code

  • Write your infrastructure in Ruby

Why use Chef?

  • Versioning on infrastructure

  • Replicate server on different providers (AWS, Linode, VirtualBox)

  • so on...

What is Chef-solo

  • Chef use a server/client model

  • Chef-solo remove the server part

Dependencies on local machine

# A chef-demo Gemfile
source "https://rubygems.org"

gem "knife-solo"
gem "librarian-chef"

Initialize a chef directory

$ knife solo init .

Initialize librarian

$ librarian-chef init

It will create a Cheffile.

Inside Cheffile

#!/usr/bin/env ruby
#^syntax detection

site 'http://community.opscode.com/api/v1'

# cookbook 'chef-client'

# cookbook 'apache2', '>= 1.0.0'

# cookbook 'rvm',
#   :git => 'https://github.com/fnichol/chef-rvm'

# cookbook 'postgresql',
#   :git => 'https://github.com/findsyou/cookbooks',
#   :ref => 'postgresql-improvements'

Prepare the remote machine

$ knife solo prepare root@192.168.5.164

It will do 2 things:

  • SSH to the remote server and install chef

  • Create a json file in nodes dir

Add cookbook in Cheffile

#!/usr/bin/env ruby
#^syntax detection

site 'http://community.opscode.com/api/v1'

cookbook "nginx"

Demo for installing Nginx

Add Nginx to runlist in nodes json

In nodes/192.168.5.164.json:
{
  "run_list":["recipe[nginx::source]"]
}

Time to cook!

$ knife solo cook root@192.168.5.164

Q&A

The code is on github: https://github.com/linc01n/chef-demo

http://chef-solo-intro.lincoln.hk