VMwareで作ったCentOS 6の仮想マシンに入れてきますよー
Chefインストール前の準備
CentOS 6のRubyは1.8系なのでバージョンを上げていきます。
# CentOSのリポジトリにないパッケージがあるのでリポジトリを追加
curl -O http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
rpm --import RPM-GPG-KEY-EPEL-6
vi /etc/yum.repos.d/epel.repo
# 下記を追記
[epel]
name=EPEL RPM Repository for Red Hat Enterprise Linux
baseurl=http://ftp.riken.jp/Linux/fedora/epel/6/$basearch/
gpgcheck=1
enabled=0
yum install openssl-devel readline-devel zlib-devel curl-devel
yum -y install --enablerepo=epel git libyaml-devel
curl -O http://www.dnsbalance.ring.gr.jp/archives/lang/ruby/ruby-1.9.3-p448.tar.gz
cd /usr/local/src
tar zxpf ruby-1.9.3-p448.tar.gz
cd ruby-1.9.3-p448
./configure --disable-install-doc
make
make install
Chefのインストール
# gem i rake --no-ri --no-rdoc
# gem i chef --no-rdoc --no-ri
# knife configure
# gem i knife-solo --no-ri --no-rdoc
## chef用のユーザを作る場合
# groupadd -g 2000 chef
# useradd -g chef -u 2002 chefsolo
# chmod 755 /home/chefsolo
# su - chefsolo
# cd ~
# mkdir tmp
# knife solo init chef-repo
# cd chef-repo
## バージョン管理
# git config --global user.email "you@example.com"
# git config --global user.name "Your Name"
# git init
# git add .
# git commit -m \'first commit\'
# cat<solo.rb
file_cache_path "/home/chefsolo/tmp/chef-solo"
data_bag_path "/home/chefsolo/chef-repo/data_bags"
#encrypted_data_bag_secret "/home/chefsolo/chef-repo/data_bag_key"
cookbook_path [ "/home/chefsolo/chef-repo/site-cookbooks",
"/home/chefsolo/chef-repo/cookbooks" ]
role_path "/home/chefsolo/chef-repo/roles"
EOF
## 実行するレシピの登録
# cat<nodes/localhost.json
{
"run_list": [ "recipe[RECIPE_NAME]" ]
}
EOF
## レシピの追加方法
# knife cookbook create RECIPE_NAME -o site-cookbooks/
# chef-soloの実行
# chef-solo -c solo.rb -j nodes/localhost.json
作業メモをざっとのっけました。
各ツール、レシピの設定等については改めて公開していきます!