Skip to content

Instantly share code, notes, and snippets.

@torrancew
Created March 1, 2012 16:13
Show Gist options
  • Save torrancew/1950911 to your computer and use it in GitHub Desktop.
Save torrancew/1950911 to your computer and use it in GitHub Desktop.
Puppet Capistrano Deploy
require 'capistrano_colors'
color_matchers = [
{ :match => /keeping \d+ of \d+ deployed releases/, :color => :green, :prio => 10 },
{ :match => /command finished in \d+ms/, :color => :cyan, :prio => 10 },
{ :match => /(^servers:|executing command$)/, :color => :magenta, :prio => 10 },
{ :match => /(transaction|error)/, :color => :red, :prio => 10 },
## PuppetRun heading matchers
{ :match => /^PuppetRun Host Summary/, :color => :blue, :prio => 10 },
{ :match => /^PuppetRun (\w+) Breakdown/, :color => :cyan, :prio => 10 },
## PuppetRun host summary matchers
{ :match => /^host=(\w+): status=ok/, :color => :green, :prio => 10 },
{ :match => /^host=(\w+): status=[^(ok)]/, :color => :red, :prio => 10 },
## PuppetRun resource matchers
{ :match => /^total: \d+$/, :color => :cyan, :prio => 10 },
{ :match => /^(failed|changed|out_of_sync|restarted|skipped): 0$/, :color => :green, :prio => 10 },
{ :match => /^(failed|out_of_sync): [1-9]/, :color => :red, :prio => 10 },
{ :match => /^(changed|restarted|skipped): [1-9]/, :color => :yellow, :prio => 10 },
## PuppetRun time matchers
{ :match => /^(last_run|total): [\.0-9]+/, :color => :cyan, :prio => 10 },
# Cfg retrieval
{ :match => /^config_retrieval: 0\./, :color => :green, :prio => 10 },
{ :match => /^config_retrieval: [1-5]\./, :color => :yellow, :prio => 10 },
{ :match => /^config_retrieval: [\.0-9]+$/, :color => :red, :prio => 5 },
# File resources
{ :match => /^file: [0-9]\./, :color => :green, :prio => 10 },
{ :match => /^file: [\.0-9]+$/, :color => :yellow, :prio => 5 },
# Filebucket resources
{ :match => /^filebucket: [0-9]\./, :color => :green, :prio => 10 },
{ :match => /^filebucket: [\.0-9]+$/, :color => :yellow, :prio => 5 },
# Package resources
{ :match => /^package: [0-9]\./, :color => :green, :prio => 10 },
{ :match => /^package: [\.0-9]+$/, :color => :yellow, :prio => 5 },
# Service resources
{ :match => /^service: [0-4]\./, :color => :green, :prio => 10 },
{ :match => /^service: [5-9]\./, :color => :yellow, :prio => 10 },
{ :match => /^service: [\.0-9]+$/, :color => :red, :prio => 5 },
# Exec resources
{ :match => /^exec: [0-4]\./, :color => :green, :prio => 10 },
{ :match => /^exec: [5-9]\./, :color => :yellow, :prio => 10 },
{ :match => /^exec: [\.0-9]+$/, :color => :red, :prio => 5 },
]
colorize( color_matchers )
load 'deploy' if respond_to?(:namespace)
require 'rubygems'
require 'capistrano'
require 'railsless-deploy'
load 'config/deploy'
load 'config/cap_colors' # Optional; uses the capistrano_colors gem to customize output colorization
config = YAML.load( File.open( 'config/deploy.yml' ).read )
set :application, 'puppet-modules'
set :repository, config['repo']
set :deploy_to, config['deploy_to']
set :use_sudo, config['use_sudo']
set :deploy_via, :remote_cache
set :keep_releases, config['keep_releases']
set :scm, :git
set :git_enable_submodules, 1
role :master, config['master']
# role :enc, config['enc_node']
set :user, config['user']
after 'deploy:update', 'deploy:cleanup'
---
repo: git://github.com/user/example.git
deploy_to: /usr/local/share/deploy/example
user: deploy
use_sudo: false
keep_releases: 3
master: puppet.example.com
enc_node: foreman.example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment