Skip to content

Instantly share code, notes, and snippets.

@cloudartisan
Created June 21, 2011 08:33
Show Gist options
  • Save cloudartisan/1037460 to your computer and use it in GitHub Desktop.
Save cloudartisan/1037460 to your computer and use it in GitHub Desktop.
Basis for pushing/installing/updating Puppet using Capistrano (via rodjek)
require 'rubygems'
require 'railsless-deploy'
set :application, "puppet"
set :use_sudo, true
set :deploy_to, "/var/assistly/puppet/git"
set :keep_releases, 2
set :scm, "git"
set :repository, "git+ssh://git@github-puppet/github/puppet.git"
set :local_repository, "git+ssh://[email protected]/github/puppet.git"
set :scm_verbose, false
task :production do
role :app, "[redacted]"
set :branch, "master"
end
task :staging do
role :app, "[redacted]"
set :branch, "newstaging"
end
task :profiling do
end
task :qa do
end
namespace :deploy do
task :default do
update
restart
cleanup
end
task :restart, :roles => :app do
run "make -C #{deploy_to}/current manifests/modules.pp"
run "/usr/local/bin/god restart puppetmaster"
end
end
module SudoEverywhere
def self.included(base)
base.send :alias_method, :run_without_sudo, :run
base.send :alias_method, :run, :run_with_sudo
end
def run_with_sudo(cmd, options={}, &block)
cmd = %{sudo su - -c "#{cmd}"} unless cmd.include?('sudo')
run_without_sudo(cmd, options, &block)
end
end
Capistrano::Configuration.send(:include, SudoEverywhere)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment