Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save otzoran/8717917 to your computer and use it in GitHub Desktop.
Save otzoran/8717917 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# -------------------------------------------------
# set ruby version
RUBYVERSION=1.9.3-p429
# RUBYVERSION=system
CHEFDIR=/var/lib/chef
export PATH=/usr/local/sbin:/usr/local/bin:$PATH
DISTRIBUTION=`lsb_release -si`
mkdir -p $CHEFDIR; cd $CHEFDIR
# -------------------------------------------------
# basic packages
if [ $DISTRIBUTION == "Fedora" ]; then
yum update
yum install openssl-devel zlib-devel libyaml-devel git readline-devel
elif [ $DISTRIBUTION == "Ubuntu" ]; then
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev git
else
echo "Distribution $DISTRIBUTION not yet supported"
exit 1
fi
# -------------------------------------------------
# install ruby
if [ "$RUBYVERSION" != "system" ]; then
$(\
cd /tmp; \
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-${RUBYVERSION}.tar.gz ;\
tar -xvzf ruby-${RUBYVERSION}.tar.gz ;\
cd ruby-${RUBYVERSION}/ ;\
./configure --prefix=/usr/local --enable-shared && make && make install ; \
)
hash -r
# -- check ruby version
CURRENT=`ruby -v | grep " ${RUBYVERSION/-/} "`
if [ "$CURRENT" == "" ]; then
echo "WRONG RUBY VERSION, should be ${RUBYVERSION}, please check ruby -v and your path"
exit 1
fi
fi
# --------------------------------------------------------------------------------
# .gemrc for root
cat > $HOME/.gemrc << EOF_GEMRC
---
# http_proxy: http://192.0.2.1:3128/
:update_sources: true
:sources:
- http://gems.rubyforge.org/
- http://gems.github.com
:benchmark: false
:bulk_threshold: 1000
:backtrace: false
:verbose: true
# gem: --no-ri --no-rdoc
install: --no-ri --no-rdoc --env-shebang
update: --no-rdoc --no-ri --env-shebang
EOF_GEMRC
# --------------------------------------------------------------------------------
# installing chef, librarian-chef and bundler
gem install chef ruby-shadow bundler --no-ri --no-rdoc --env-shebang
gem install librarian-chef --no-ri --no-rdoc --env-shebang
# --------------------------------------------------------------------------------
# .gitignore :
# with vagrant you should set this in your vagrant machine directory
# and stop the procedure here
cat > $CHEFDIR/.gitignore << EOF_GITIGNORE
/cookbooks
/tmp
*.swp
/bootstrap
/vagrant
EOF_GITIGNORE
# --------------------------------------------------------------------------------
# create a solo.rb for chef-solo:
# - cookbooks is only for librarian-chef cookbooks
# - local cookbooks goes to site-cookbook
cat > $CHEFDIR/solo.rb << SOLO_EOF
http_proxy "#{ENV['http_proxy']}"
https_proxy "#{ENV['http_proxy']}"
cookbook_path [
File.expand_path("../cookbooks", __FILE__),
File.expand_path("../site-cookbooks", __FILE__),
]
json_attribs File.expand_path("../node.json", __FILE__)
SOLO_EOF
echo "Done. Please check $CHEFDIR/solo.rb, $CHEFDIR/.gitignore and $HOME/.gemrc"
@otzoran
Copy link
Author

otzoran commented Jan 30, 2014

implied: executed as root.

  1. sudo the sections where approp.
  2. function the block under install ruby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment