LoginSignup
33
33

More than 5 years have passed since last update.

CentOS 6.3で、シェルスクリプト一発でchefまでインストールする

Posted at

そもそも、そういうVM作っておくのが一番早いんですが、直でやる場合のシェルスクリプトを作ってみた。
でも、エラー処理も無く、逐次実行してるだけの超簡易なので、ネットワーク環境やその時のRubyの配布状況などを確認して利用してください。

# root executes this script

# Install Libraries for build
yum -y install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison wget unzip git 

# Download Ruby
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar xvzf ruby-1.9.3-p327.tar.gz

# Create Install Directory
mkdir /opt/ruby

# Configure and Compile
cd ruby-1.9.3-p327
./configure --prefix /opt/ruby
make
make install

cd

# Chef Install
/opt/ruby/bin/gem install chef

# Clone Cookbooks
git clone git://github.com/opscode/cookbooks.git chef-cookbooks

# Create Chef Directories
mkdir /etc/chef
mkdir /var/chef-solo

# Initial Setting
echo -e "file_cache_path \"/var/chef-solo\"\njson_attribs \"/etc/chef/node.json\"\ncookbook_path \"/root/chef-cookbooks\"" > /etc/chef/solo.rb

echo '{ "run_list": [] }' > /etc/chef/node.json

# Write run_list
# /opt/bin/chef-solo

/opt/rubyに入れているのは、後から削除したりちゃんと入れ直す時のためで、一時的な利用なのでPATHも通してません。

実際には上のスクリプトの中に、privateなリポジトリからのcookbooksのclone等も含んでいますが、公開のため削除してあります。

33
33
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
33