ユーザ用ツール

サイト用ツール


chef:chef-build.sh

環境構築用のスクリプト

  • 文字コード:UTF-8
  • 改行:LF

base

#!/bin/bash

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 

# rbenv
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="${HOME}/.rbenv/bin:${PATH}"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
export PATH="${HOME}/.rbenv/bin:${PATH}"
eval "$(rbenv init -)"

mkdir -p ~/.rbenv/plugins
cd ~/.rbenv/plugins
git clone git://github.com/sstephenson/ruby-build.git

rbenv install 1.9.3-p327
rbenv global 1.9.3-p327
rbenv rehash

gem install chef
rbenv rehash

# Clone Cookbooks
mkdir ~/chef
cd ~/chef
git clone git://github.com/opscode/cookbooks.git cookbooks

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

# Initial Setting
cat << EOS > /etc/chef/solo.rb
file_cache_path "/var/chef-solo"
cookbook_path ["/root/chef/cookbooks"]
role_path "/root/chef/role"
json_attribs "/etc/chef/node.json"
log_level :debug
EOS

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

CentOS 5.9にて調整

#!/bin/bash
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm 

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 

# rbenv
rm -rf ~/.rbenv
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc

# ruby-build
rm -rf /tmp/ruby-build
git clone git://github.com/sstephenson/ruby-build.git /tmp/ruby-build
cd /tmp/ruby-build
./install.sh

# ruby
rbenv install 1.9.3-p327
rbenv global 1.9.3-p327
rbenv rehash

# chef & knife
gem install chef --no-ri --no-rdoc
gem install knife-solo --no-ri --no-rdoc
gem install capistrano --no-ri --no-rdoc
source ~/.bashrc 

# initialize
cd ~
knife solo init chef-solo
knife cookbook create sample -o ./chef-solo/cookbooks/
echo '{ "run_list": ["recipe[sample]"] }' > /root/chef-solo/node.json

rm -rf /root/chef-solo/solo.rb
cat << EOS > /root/chef-solo/solo.rb
file_cache_path "/tmp/chef-solo"
cookbook_path ["/root/chef-solo/cookbooks"]
role_path "/root/chef/role"
json_attribs "/tmp/chef-solo/roles"
log_level :debug
EOS


echo "e.g.) chef-solo -c /root/chef-solo/solo.rb -j /root/chef-solo/node.json"

CentOS 6.4で調整

#!/bin/bash

##
## chef-build for CentOS 6.x 
##

#rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
#rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
#rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

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 --exclude=*.i386

# rbenv
rm -rf ~/.rbenv
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc

# ruby-build
rm -rf /tmp/ruby-build
git clone git://github.com/sstephenson/ruby-build.git /tmp/ruby-build
cd /tmp/ruby-build
./install.sh

# ruby
rbenv install 1.9.3-p327
rbenv global 1.9.3-p327
rbenv rehash

# chef & knife
gem install chef --no-ri --no-rdoc
gem install knife-solo --no-ri --no-rdoc
gem install capistrano --no-ri --no-rdoc
source ~/.bashrc

## initialize
#cd ~
#knife solo init chef-solo
#knife cookbook create sample -o ./chef-solo/cookbooks/
#echo '{ "run_list": ["recipe[sample]"] }' > /root/chef-solo/node.json
#
#rm -rf /root/chef-solo/solo.rb
#cat << EOS > /root/chef-solo/solo.rb
#file_cache_path "/tmp/chef-solo"
#cookbook_path ["/root/chef-solo/cookbooks"]
#role_path "/root/chef/role"
#json_attribs "/tmp/chef-solo/roles"
#log_level :debug
#EOS


echo "run 'source ~/.bashrc' & test chef-solo"
echo "e.g.) chef-solo -c /root/chef-solo/solo.rb -j /root/chef-solo/node.json"
chef/chef-build.sh.txt · 最終更新: 2013/05/24 01:33 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki