Skip to content

Instantly share code, notes, and snippets.

default {
execute 'SendDTMF', '1111', '100'
}
7/29/10 11:38:44 PM [0x0-0x8c08c].com.topfunky.PeepOpen[2672] Unknown option: `-l'
7/29/10 11:38:44 PM [0x0-0x8c08c].com.topfunky.PeepOpen[2672] Usage: tcsh [ -bcdefilmnqstvVxX ] [ argument ... ].
7/29/10 11:41:54 PM [0x0-0x8c08c].com.topfunky.PeepOpen[2672] Unknown option: `-l'
7/29/10 11:41:54 PM [0x0-0x8c08c].com.topfunky.PeepOpen[2672] Usage: tcsh [ -bcdefilmnqstvVxX ] [ argument ... ].
module BundlerSupport
def bundler_dependencies(options = {})
root = options.delete(:root)
# WARNING: This is highly Bundler 0.9 -specific
YAML::load_file(File.join(root, 'Gemfile.lock'))['specs'].each do |spec|
gem_name = spec.keys.first
dependent_recipe = "#{gem_name.gsub(/-/, '_')}_gem_dependencies".to_sym
if method_defined?(dependent_recipe)
@eric
eric / application_manifest.rb
Created June 26, 2010 00:05
fact-specific configuration for moonshine.yml
# Provide a :rails_env fact
Facter.add(:rails_env) do
setcode do
ENV["RAILS_ENV"] || 'production'
end
end
# Your application manifest
class ApplicationManifest < Moonshine::Manifest
# Let us use non-symbol keys in the moonshine.yml
exec { 'first':
command => '/usr/bin/true',
unless => '/bin/test -f ./mark.txt'
}
exec { 'second':
command => '/usr/bin/false',
subscribe => Exec['first'],
refreshonly => true
}
# A mechanism for shadow_puppet to install source packages
module Moonshine
module SourcePackage
def source_package(name, options = {})
build_root = options[:build_root] || '/usr/src'
dist_root = options[:dist_root] || File.join(build_root, 'dist')
url = options[:url]
filename = options[:filename] || File.basename(url)
expanded_directory = options[:expanded_directory] || filename[/^(.+)\.(tar|tgz|tbz)/, 1]
expanded_root = options[:expanded_root] || File.join(build_root, expanded_directory)
# estimate the duration of an ALTER TABLE statement in mysql
# this code estimates the worst case, as most of the time, an ALTER will result in a table that is smaller than the original
percentage = 0
interval = 10
while(true) do
sleep(interval)
new_percentage = (File.size('#sql-5316_1a.ibd').to_f / File.size('moves.ibd').to_f)
change = new_percentage - percentage
intervals = 1.0/change
def Facter.case(name, whens)
if whens[:default].is_a?(Exception)
default = proc { raise whens[:default] }
elsif whens[:default].is_a?(Proc)
default = whens[:default]
elsif whens[:default]
default = proc { whens[:default] }
else
default = proc { |value| raise "Unsupported case for '#{name}': #{value}" }
end
class ApplicationManifest < Moonshine::Manifest
def ntp
package 'ntp', :ensure => :latest
case Facter.lsbdistid
when 'Ubuntu'
service 'ntp', :alias => 'ntp', :ensure => :running,
:require => package('ntp'), :pattern => 'ntpd'
when 'Fedora', 'RedHat'
service 'ntpd', :alias => 'ntp', :ensure => :running,
@eric
eric / capistrano_roles.rb
Created June 10, 2010 05:13
Add support to capistrano for $CAPISTRANO:ROLES$
::Capistrano::Command.class_eval do
def replace_placeholders(command, channel)
command = command.dup
command.gsub!(/\$CAPISTRANO:HOST\$/, channel[:host])
command.gsub!(/\$CAPISTRANO:ROLES\$/, channel[:server].roles.join(','))
command
end
end
::Capistrano::ServerDefinition.class_eval do