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
# -*- mode: ruby; coding: utf-8 -*- | |
# Requires fog gem. | |
# Configure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in config/rake.rb | |
desc <<EOF | |
Delete nodes and clients for nonexistent EC2 instances from chef server | |
YES=1 variable makes task skip confirmation questions. | |
EOF |
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
# -*- ruby -*- | |
# Needs following parameters configured in rake.rb: | |
# DNS_DOMAIN: domain for which to set entries, including trailing dot | |
# (e.g. "example.com.") | |
# DNS_ATTRIBUTE: attribute containing hostname to CNAME to, defaults | |
# to 'fqdn'; for EC2, use "ec2.public_hostname" | |
# DNS_ENTRIES: hash mapping hostname to node search query, | |
# e.g. {'buildbot' => 'recipes:buildbot', 'monitoring' => | |
# 'roles:monitoring'} |
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
# ~/.chef/shef.rb | |
begin | |
# Load configuration from knife.rb | |
require 'chef/knife' | |
Chef::Knife.new.configure_chef | |
rescue | |
puts <<-EOF | |
Can't load knife config: #{$!} | |
This is probably nothing serious. | |
EOF |
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
# backports_apt_package.rb | |
# | |
# Resource and provider to correctly install packages from Debian's | |
# backports, which are a non-default apt source. Creates | |
# backports_apt_package resource which does the Right Thing. | |
# | |
# Drop this file into cookbook's libraries/ dir. | |
require 'chef/provider/package/apt' | |
require 'chef/resource/package' |
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
class Chef | |
class Util | |
class FileEdit | |
public | |
# Run block for matching lines, passing it matching line. | |
# Replaces matching lines with value returned by the block. | |
def g(regex) | |
exp = Regexp.new(regex) | |
new_contents = [] | |
contents.each do |line| |
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
# knife.rb config snippet to make knife ssh command use your own login | |
# instead of hard-coded `root', `ubuntu' or other name. Tries to get | |
# login for your domain from ~/.ssh/config and if it's not found | |
# there, uses your local login. | |
require 'net/ssh' | |
require 'etc' | |
knife[:ssh_user] = | |
Net::SSH::Config.for('some.host.inside.your.domain')[:user] || |
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
#!/usr/bin/perl -w | |
# | |
# check_with_hysteresis.pl - hysteresis for nagios service checks' limits | |
# | |
# Usage: check_with_hysteresis.pl $LASTSERVICESTATE$ default check --- STATE1 check for state1 --- STATE2 check for state2 ... | |
# | |
# If $LASTSERVICESTATE$ is STATE1, "check for state1" will be | |
# executed, if it's STATE2, "check for state2" will be executed, and | |
# so on; if state is undefined, "default check" wil be executed. | |
# |
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
# Example usage: | |
# perl_module_build "0.3601" | |
define :perl_module_build do | |
execute "/usr/local/bin/cpan_install Module::Build" do | |
cwd "/root" | |
path [ "/usr/local/bin", "/usr/bin", "/bin" ] | |
not_if { `perl -mModule::Build -e 'print $Module::Build::VERSION'`.to_f >= params[:name].to_f } | |
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
on js(jscpt) | |
set jscpt to "(function _l () {" & jscpt & "}());" | |
tell application "Safari" to do JavaScript jscpt in document 1 | |
end js | |
on log_into_google(method, username, password) | |
tell application "Safari" to set URL of document 1 to "https://accounts.google.com/" & method | |
delay 2 | |
js("var f = document.getElementById('gaia_loginform'); | |
f.Email.value = '" & username & "'; |
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
# Chef resources describing how to set up package repository server, | |
# simplified fromactual cookbook (not open sourced yet). Sets up apt | |
# repository in /srv/apt directory, with system user "apt-repo". Packages | |
# are GPG-signed to prevent apt-get from complaining on every install. | |
# | |
# Directory /srv/apt should be reachable to clients via http or other | |
# means. This is left as an exercise for the reader. | |
# | |
# For extra explanations, see: | |
# http://joseph.ruscio.org/blog/2010/08/19/setting-up-an-apt-repository/ |