chef 安裝

 

Chef Installation Guide

Thursday, June 02, 2011

1:38 PM

 

This document targets for Ruby 1.8.7 + RubyGems 1.6.2 + Chef 0.10.0., it's based on the Chef Wiki and contains adjustments to fit into Citi's environment:

http://wiki.opscode.com/display/chef/Bootstrap+Chef+RubyGems+Installation

http://wiki.opscode.com/display/chef/Bootstrap+Client+RubyGems

 

1.       Prerequisite:

Verify the server has Fully Qualified Domain Name.

 

Login as root.

 

2.       Install Ruby / On Red Hat and CentOS (Version 5 only) :

For RHEL 5 x86-64:

 

cd /tmp

export http_proxy=http://webproxy.wlb2.nam.nsroot.net:8080

wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

rpm -i epel-release-5-4.noarch.rpm

wget -O /etc/yum.repos.d/aegis.repo http://rpm.aegisco.com/aegisco/el5/aegisco.repo

export http_proxy=

 

Go to /etc/yum.repos.d, add proxy definitions to all  repositories in aegis.repo, epel.repo and epel-testing.repo:

proxy=http://webproxy.wlb2.nam.nsroot.net:8080

 

Create  RubyGems configuration file (~/.gemrc):

gem: --no-ri --no-rdoc --http-proxy http://webproxy.wlb2.nam.nsroot.net:8080

 

Create Git configuration file (~/.gitconfig):

[user]

name =

email =

[core]

autocrlf = true

safecrlf = false

[http]

proxy = http://webproxy.wlb2.nam.nsroot.net:8080

 

Install Ruby and dependencies:

cd /tmp

yum -y  install gecode gecode-devel ruby rubygems ruby-static git gcc-c++ make

gem install rake rake-compiler

gem install rspec -v 2.5.0

git clone http://github.com/manderson26/dep-selector.git

cd dep-selector

rake compile

rake spec

 

3.       Install Chef and Ohai:

gem install chef chef-server chef-server-api chef-server chef-solr chef-server-webui ohai

 

4.       Config Chef Solo:

Edit /etc/chef/solo.rb:

file_cache_path "/tmp/chef-solo"

cookbook_path "/tmp/chef-solo/cookbooks"

 

5.       Download cookbooks for bootstrap installation:

cd /tmp

mkdir -p /tmp/chef-solo/cookbooks

export http_proxy=http://webproxy.wlb2.nam.nsroot.net:8080

wget http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz

tar zxvf bootstrap-latest.tar.gz

cp -pr cookbooks/* /tmp/chef-solo/cookbooks

 

6.       Bootstrap Chef Server:

Edit ~/chef.json to create server configurations:

{

  "chef_server": {

    "server_url": "http://localhost:4000",

    "webui_enabled": true,

    "init_style": "init"

  },

  "run_list": [ "recipe[chef-server::rubygems-install]" ]

}

 

Open /tmp/chef-solo/cookbooks/chef-server/recipes/rubygems-install.rb and comment the line below:

when "centos","redhat","fedora"

 

  include_recipe "couchdb"

  include_recipe "java"

  include_recipe "rabbitmq::chef"

#  include_recipe "gecode"

 

Start server bootstrap installation:

chef-solo -c /etc/chef/solo.rb -j ~/chef.json

 

7.       Verify That All Components are Running:

Follow the instruction from wiki.

 

8.       Configure the Command Line Client:

Follow the instruction from wiki.

 

9.       Verify Your Knife Client Configuration:

Follow the instruction from wiki.

 

10.   Create a Knife Client for Your Laptop/Desktop:

Follow the instruction from wiki.

 

11.   Bootstrap Chef Client:

Login as root on client.

 

Edit ~/chef.json:

{

  "chef_client": {

    "init_style": "init"

  },

  "run_list": [ "recipe[chef-client::delete_validation]",

                                  "recipe[chef-client::config]",

                                   "recipe[chef-client]" ]

}

 

Start client bootstrap installation:

chef-solo -c /etc/chef/solo.rb -j ~/chef.json

 

Update server url in /etc/chef/client.rb:

chef_server_url  "http://cloudmwdc80.nam.nsroot.net:4000"

 

Update interval (second) in /etc/sysconfig/chef-client:

INTERVAL=60

 

In order to register with the server,  we need to copy validation certificate from the server.

scp cloudmwdc80:/etc/chef/validation.pem /etc/chef

 

Restart chef-client service, the chef client will synchronize with the server every 60 seconds.

service chef-client restart

 

12.   Verify Client/Server Installation:

Follow the cookbook quick start to verify installation:

http://wiki.opscode.com/display/chef/Cookbook+Quick+Start

發佈了26 篇原創文章 · 獲贊 3 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章