Last active
January 4, 2016 14:48
-
-
Save rcmorano/5056474 to your computer and use it in GitHub Desktop.
Debian 'chef-server' bootstrap script that deploys with rvm, librarian (automagical cookbook download) and chef-solo. It's supposed to be easily maintenable since it completely relays on community cookbooks :]
COPY PASTE: wget -O /tmp/bootstrap.tgz https://gist.github.com/rcmorano/5056474/download; bash /tmp/$(tar zxvf /tmp/bootstrap.tgz -C /tmp…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CHEF_REPO=/var/lib/chef-repo | |
CHEF_FILE=/tmp/Cheffile; test -d $(dirname $CHEF_FILE) || mkdir -p $(dirname $CHEF_FILE) | |
SOLO_RB=/etc/chef/solo.rb; test -d $(dirname $SOLO_RB) || mkdir -p $(dirname $SOLO_RB) | |
SOLO_JSON=/etc/chef/solo.json; test -d $(dirname $SOLO_JSON) || mkdir -p $(dirname $SOLO_JSON) | |
GEM_PREDEPENDS="librarian chef" | |
RVM_RUBY_VER=1.9.2 | |
# changed rvm installation from rvm-cookbook to rvm.io scripts again | |
curl -#L https://get.rvm.io | bash -s stable --autolibs=3 --ruby | |
source /etc/profile.d/rvm.sh | |
rvm autolibs enable | |
rvm install ruby-$RVM_RUBY_VER | |
rvm use --default ruby-$RVM_RUBY_VER | |
gem install --no-ri --no-rdoc $GEM_PREDEPENDS | |
# now that we have rvm, use librarian to download cookbooks | |
cat > $CHEF_FILE << EOF | |
cookbook 'chef-server' | |
EOF | |
# let librarian do its magic | |
test -d $CHEF_REPO || git clone git://github.com/opscode/chef-repo.git $CHEF_REPO | |
cd $CHEF_REPO | |
test -f Cheffile && rm Cheffile | |
librarian-chef init | |
cat $CHEF_FILE >> Cheffile | |
librarian-chef install | |
# set /etc/chef/solo.rb | |
cat > $SOLO_RB << EOF | |
file_cache_path "/tmp/chef-solo" | |
cookbook_path "$CHEF_REPO/cookbooks" | |
EOF | |
# bootstrap chef-server | |
cat > $SOLO_JSON << EOF | |
{ | |
"chef-server": { | |
"configuration": { | |
"chef_server_webui": { | |
"enable": true | |
} | |
} | |
}, | |
"run_list": [ "recipe[chef-server::default]" ] | |
} | |
EOF | |
chef-solo -c $SOLO_RB -j $SOLO_JSON |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment