Last active
April 26, 2016 13:26
-
-
Save pheisiph/5656614 to your computer and use it in GitHub Desktop.
Puppet Bootstrapping with capistrano
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
#config/recipes/bootstrap.rb | |
#capistrano recipe | |
namespace :bootstrap do | |
desc "Prepare the system to run Puppet. Requires root access (once)." | |
task :default do | |
set :user, 'root' # because we haven't provisioned any users yet | |
# install puppet standalone | |
run "wget http://apt.puppetlabs.com/puppetlabs-release-#{config['os_code_name']}.deb" | |
run "dpkg -i puppetlabs-release-#{config['os_code_name']}.deb" | |
run "apt-get -y update" | |
run "apt-get -y install puppet-common" | |
run "rm puppetlabs-release-#{config['os_code_name']}.deb" | |
# We need this fix on some systems in order to get build-essential | |
# to be install correctly. If that fails, uncomment this. | |
# `dpkg -l libc6 libc6-dev` | |
# `apt-cache madison libc6 libc6-dev` | |
# should provide hints as to which versions need to be installed. | |
# run 'apt-get -y install --reinstall libc6=2.15-0ubuntu10.4 libc6-dev=2.15-0ubuntu10.4' | |
end | |
end |
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
#/config/recipes/puppet.rb | |
# This runs once as root after bootstrapping, and in the future as the deployer user | |
namespace :puppet do | |
desc "Provision the server by applying this project's Puppet config" | |
task :default do | |
# create a tarball of the puppet directory and upload to the server | |
system "mkdir -p ./tmp && tar czf './tmp/puppet.tgz' puppet/" | |
upload "./tmp/puppet.tgz","/tmp/puppet.tgz", :via => :scp | |
# unpack the tarball and replace the old puppet system config | |
run "tar xzf /tmp/puppet.tgz" | |
run "rm -rf /etc/puppet" | |
run "mv puppet/ /etc/puppet" | |
system 'rm ./tmp/puppet.tgz' # cleanup | |
# let the puppets dance! | |
try_sudo "puppet apply /etc/puppet/manifests/site.pp" | |
end | |
end | |
# And in your deploy.rb add | |
# after "bootstrap", "puppet" | |
# to run this task right after bootstrapping as root once. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment