LoginSignup
3
3

More than 5 years have passed since last update.

CentOS7(Redhat)でChefを使えるようにするshell

Last updated at Posted at 2015-03-13

rootで作業する場合

chef_envsetting
#!/bin/sh -x
#############################################################
# install package
PKG="gcc make zlib zlib-devel openssl openssl-devel git libffi-devel readline-devel wget bzip2"
# install ruby version
RB_VER="2.3.1"
# install gem version (https://rubygems.org/)
RB_GEM="2.6.6"
# install Chef Client Package (https://downloads.chef.io/chef-client/redhat/#/)
CHEF_PKG=chef-12.14.89-1.el7.x86_64.rpm
#############################################################
# package install
yum -y install ${PKG}
wget https://packages.chef.io/stable/el/7/${CHEF_PKG}
rpm -ivh ${CHEF_PKG}

# checkoud ruby
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

# rbenv setting
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ${HOME}/.bash_profile
echo $PATH

# checkout ruby-build
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

# ruby install
rbenv install ${RB_VER}
rbenv rehash
rbenv global ${RB_VER}

# download ruby-gems
git clone https://github.com/rubygems/rubygems
wget https://rubygems.org/rubygems/rubygems-${RB_GEM}.tgz
cd rubygems
ruby setup.rb

# install knife solo
gem install knife-solo --no-ri --no-rdoc

一般ユーザで作業する場合

前提はrpm類がインストールされていること

chef_envsetting
#!/bin/sh -x
#############################################################
# install ruby version
RB_VER="2.3.1"
# install gem version (https://rubygems.org/)
RB_GEM="2.6.6"
#############################################################
# checkoud ruby
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

# rbenv setting
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ${HOME}/.bash_profile
echo $PATH

# checkout ruby-build
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

# ruby install
rbenv install ${RB_VER}
rbenv rehash
rbenv global ${RB_VER}

# download ruby-gems
wget https://rubygems.org/rubygems/rubygems-${RB_GEM}.tgz
tar zxvf rubygems-${RB_GEM}.tgz
cd rubygems-${RB_GEM}
ruby setup.rb

# install knife solo
gem install knife-solo --no-ri --no-rdoc
3
3
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
3
3