Created
November 28, 2012 01:04
-
-
Save anonymous/4158321 to your computer and use it in GitHub Desktop.
Chef Server bootstrap script for Ubuntu 12.04LTS Server amd64
This file contains hidden or 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
# | |
# Chef server config (should end up at /etc/chef/server.rb) | |
# | |
log_level :info | |
log_location STDOUT | |
umask 0022 | |
checksum_path "/var/chef/cookbook_index" | |
chef_server_url "http://localhost:4000" | |
cookbook_path [ "/var/chef/chef-repo/cookbooks", "/var/chef/chef-repo/site-cookbooks" ] | |
cookbook_tarball_path "/var/chef/cookbook-tarballs" | |
file_cache_path "/var/cache/chef" | |
node_path "/var/chef/node" | |
role_path "/var/chef/roles" | |
sandbox_path "/var/cache/chef/sandboxes" | |
search_index_path "/var/chef/search_index" | |
validation_client_name "chef-validator" | |
signing_ca_cert "/etc/chef/certificates/cert.pem" | |
signing_ca_key "/etc/chef/certificates/key.pem" | |
signing_ca_path "/var/chef/ca" | |
signing_ca_user "chef" | |
signing_ca_group "chef" | |
ssl_verify_mode :verify_none | |
couchdb_database 'chef' | |
persistent_queue true | |
Mixlib::Log::Formatter.show_time = false | |
# | |
# solr config | |
# | |
supportdir = "/var/chef" | |
solr_jetty_path File.join(supportdir, "solr", "jetty") | |
solr_data_path File.join(supportdir, "solr", "data") | |
solr_home_path File.join(supportdir, "solr", "home") | |
solr_heap_size "256M" | |
solr_url "http://localhost:8983" | |
amqp_pass "testing" | |
# | |
# web UI config | |
# | |
web_ui_client_name "chef-webui" | |
web_ui_key "/etc/chef/webui.pem" | |
web_ui_admin_user_name "admin" | |
# Following line should include random password generated during bootstrap |
This file contains hidden or 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 | |
# | |
# (I love you, Chef, but you're kind of a pain to install.) | |
# | |
# This script assumes you have a fresh Ubuntu 12.04LTS Server amd64 system | |
# with Internet connectivity. | |
# | |
# Has been tested against various VMware and Amazon EC2 instances. | |
# | |
# Save all the files in this gist to /tmp on your target machine; | |
# they'll be referred to later. | |
# | |
# Call this script like so: | |
# $ chmod +x /tmp/server_bootstrap.sh | |
# $ sudo HOST=your-hostname-here /tmp/server_bootstrap.sh | |
# | |
# | |
# Perform system updates / general clean up | |
# | |
apt-get -y purge landscape-common apt-xapian-index && apt-get -y update && aptitude -y full-upgrade && apt-get -y autoremove | |
hostname $HOST && hostname > /etc/hostname | |
echo "127.0.1.1 $HOST" >> /etc/hosts | |
# | |
# You may wish to reboot before proceeding. | |
# | |
# Next, install dev environment/Ruby/Rubygems/useful utilities | |
# | |
ntpdate pool.ntp.org | |
apt-get -y install ruby1.9.1 ruby1.9.1-dev libopenssl-ruby build-essential curl git ssl-cert htop sysstat bwm-ng screen couchdb rabbitmq-server libgecode-dev openjdk-7-jre-headless zlib1g-dev zlib1g libxml2 libxml2-dev ntp heirloom-mailx | |
cd /tmp && wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz && tar -zxf rubygems-1.8.24.tgz && cd rubygems-1.8.24 && ruby setup.rb && cd /tmp && rm rubygems-1.8.24.tgz | |
apt-get -y clean | |
# Ensure Chef has access to RabbitMQ queues | |
rabbitmqctl add_vhost /chef | |
rabbitmqctl add_user chef testing | |
rabbitmqctl set_permissions -p /chef chef ".*" ".*" ".*" | |
# Perform the actual Chef installation via gems | |
mkdir -p /etc/chef | |
gem install chef-server chef-server-api chef-server-webui chef-solr --no-ri --no-rdoc | |
# This assumes you've saved server.rb to /tmp on the local machine. | |
# (You could also curl/wget it from the Gist itself.) | |
cp /tmp/server.rb /etc/chef/server.rb | |
useradd -r chef | |
mkdir /var/log/chef && chown -R chef /var/log/chef | |
mkdir /var/run/chef && chown -R chef /var/run/chef | |
# | |
# These commands copy the Debian-style init scripts and configuration files | |
# from the gem's support files (this path may change for different | |
# versions of Ruby) | |
# | |
# (Yes, I should probably be using Upstart-style inits. Oh well.) | |
# | |
cp /usr/lib/ruby/gems/1.9.1/gems/chef-10.16.2/distro/debian/etc/default/chef* /etc/default | |
cp /usr/lib/ruby/gems/1.9.1/gems/chef-10.16.2/distro/debian/etc/init.d/chef* /etc/init.d | |
rm /etc/chef/webui.rb; rm /etc/chef/solr.rb | |
# Keeps everything in one configuration file | |
ln -s /etc/chef/server.rb /etc/chef/webui.rb | |
ln -s /etc/chef/server.rb /etc/chef/solr.rb | |
# Prep the Chef SOLR index service's folder structure/support files | |
chef-solr-installer | |
chown -R chef /var/chef | |
chmod +x /etc/init.d/chef-* | |
# Fix startup load order based on contents of | |
/usr/lib/insserv/insserv chef-expander | |
/usr/lib/insserv/insserv chef-server | |
/usr/lib/insserv/insserv chef-server-webui | |
/usr/lib/insserv/insserv chef-solr | |
# | |
# Generate a random password for your web UI 'admin' account. | |
# See the 'web_ui_admin_default_password' line in /etc/chef/server.rb | |
# for your Web UI password. | |
# | |
echo web_ui_admin_default_password `date | sha1sum |awk '{print $1}'` >> /etc/chef/server.rb | |
# | |
# Chef services should be live after reboot. | |
# | |
# After restarting, try connecting to http://yourhostname:4040 to ensure the web UI is accessible! | |
# | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment