Skip to content

Instantly share code, notes, and snippets.

@dysinger
Created October 12, 2012 01:51
Show Gist options
  • Save dysinger/3876903 to your computer and use it in GitHub Desktop.
Save dysinger/3876903 to your computer and use it in GitHub Desktop.
Jenkins EC2 Slave Init Script
#!/bin/bash -eux
# pkgs
apt-get update
apt-get upgrade -y
apt-get install -y curl git-core
# chef
which chef-solo >/dev/null || \
curl -L http://www.opscode.com/chef/install.sh | bash
[[ ! -d /var/chef/cookbooks ]] && \
mkdir -p /var/chef/cookbooks
cd /var/chef/cookbooks
# apt, java, runit & jenkins are needed to setup jenkins
[[ ! -d /var/chef/cookbooks/apt ]] && \
git clone https://github.com/opscode-cookbooks/apt.git apt
[[ ! -d /var/chef/cookbooks/java ]] && \
git clone https://github.com/opscode-cookbooks/java.git java
[[ ! -d /var/chef/cookbooks/runit ]] && \
git clone https://github.com/opscode-cookbooks/runit.git runit
[[ ! -d /var/chef/cookbooks/chef-jenkins ]] && \
git clone https://github.com/fnichol/chef-jenkins.git jenkins
# ark, llvm & ghc cookbooks are needed for my projects to build on the slave
[[ ! -d /var/chef/cookbooks/ark ]] && \
git clone https://github.com/opscode-cookbooks/ark.git ark
[[ ! -d /var/chef/cookbooks/llvm ]] && \
git clone https://github.com/dysinger/chef-llvm.git llvm
[[ ! -d /var/chef/cookbooks/ghc ]] && \
git clone https://github.com/dysinger/chef-ghc.git ghc
# configure & run chef-solo
[[ ! -d /etc/chef ]] && \
mkdir -p /etc/chef
echo '# default config #' >/etc/chef/solo.rb
cat > /etc/chef/node.json <<\JSON
{
"java" : {
"install_flavor" : "oracle",
"jdk_version" : "6",
"oracle" : { "accept_oracle_download_terms" : true }
},
"run_list": [ "recipe[apt]",
"recipe[jenkins::node_jnlp]",
"recipe[ghc]" ]
}
JSON
chef-solo -j /etc/chef/node.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment