chef
knife
chef-solo

CentOSでchefを利用して環境構築

More than 1 year has passed since last update.


scene


  • ローカル環境で利用したレシピ(chef)を稼働想定環境で利用したい

  • 社内の誰かが作ったレシピを利用してローカル環境を構築したい


what's chef ?


  • chef(シェフ)はknife(調理用具)とcookbook(recipe:レシピ)を使い調理(環境構築)をするイメージ

  • recipeがあれば誰でも環境を構築することができる


usage

4 step

 1. chef, knifeのインストール

 2. cookbook(料理本の作成)

 3. recipeの作成

 4. 実行


console

# # 1. chef, knifeのインストール

# sudo rpm -ivh https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chefdk-0.3.0-1.x86_64.rpm
Retrieving https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chefdk-0.3.0-1.x86_64.rpm
warning: /var/tmp/rpm-tmp.K6Y37k: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
Preparing... ########################################### [100%]
1:chefdk ########################################### [100%]
Thank you for installing Chef Development Kit!
#
# chef -v
Chef Development Kit Version: 0.3.0
#
# chef gem install knife-solo
#
# # 2. cookbook(料理本の作成)
# knife solo init /var/chef
WARNING: No knife configuration file found
Creating kitchen...
Creating knife.rb in kitchen...
Creating cupboards...
Setting up Berkshelf...
#
# ls -la /var/chef/
total 44
drwxr-xr-x 9 root root 4096 Jul 6 08:57 .
drwxr-xr-x. 20 root root 4096 Jul 6 08:57 ..
drwxr-xr-x 2 root root 4096 Jul 6 08:57 .chef
-rw-r--r-- 1 root root 12 Jul 6 08:57 .gitignore
-rw-r--r-- 1 root root 35 Jul 6 08:57 Berksfile
drwxr-xr-x 2 root root 4096 Jul 6 08:57 cookbooks
drwxr-xr-x 2 root root 4096 Jul 6 08:57 data_bags
drwxr-xr-x 2 root root 4096 Jul 6 08:57 environments
drwxr-xr-x 2 root root 4096 Jul 6 08:57 nodes
drwxr-xr-x 2 root root 4096 Jul 6 08:57 roles
drwxr-xr-x 2 root root 4096 Jul 6 08:57 site-cookbooks
# knife cookbook create project -o /var/chef/site-cookbooks/
WARNING: No knife configuration file found
** Creating cookbook project
** Creating README for cookbook: project
** Creating CHANGELOG for cookbook: project
** Creating metadata for cookbook: project
# #
# # 3. recipeの作成
# vi /var/chef/site-cookbooks/project/recipes/default.rb
#
# # 4.実行
# chef-solo -o project

※ recipeをgitなどからcloneできると配布できてステキ

# git clone ssh://hoge/project.git project


reference

chefDK

knifeコマンド

cookbookとsite-cookbookの違い