Skip to content

Instantly share code, notes, and snippets.

#using value_for_platform to set a variable
config_file = value_for_platform(
["ubuntu", "debian"] => { "default" => "/etc/thing/config"},
["redhat", "centos", "fedora", "scientific", "amazon"] => { "default" => "/etc/stuff/config"},
"default" => "/usr/local/etc/source/config"
)
File config_file do
owner "root"
@btm
btm / fbsd_default.rb
Created October 1, 2011 15:30
Overriding Chef::Provider::File with a library to use wheel instead of root
# fbsd_group/recipes/default.rb
# Empty
@btm
btm / example.txt
Created July 28, 2011 00:54
Deleting an ec2 instance, chef node and chef client objects with one command.
$ function kd() { knife ec2 server delete -y $1 && knife node delete -y $1 && knife client delete -y $1 ; }
$ kd i-979e2ef6
Instance ID: i-979e2ef6
Flavor: m1.small
Image: ami-e4d42d8d
Availability Zone: us-east-1d
Security Groups: btm
SSH Key: btm
Public DNS Name: ec2-50-16-174-41.compute-1.amazonaws.com
Public IP Address: 50.16.174.41
ubuntu@ip-10-204-150-209:~$ sudo find /var/lib/couchdb/
/var/lib/couchdb/
/var/lib/couchdb/0.10.0
/var/lib/couchdb/0.10.0/.chef_design
/var/lib/couchdb/0.10.0/.chef_design/d0d90ee5abfd2c81967085c438c29547.view
/var/lib/couchdb/0.10.0/.chef_design/be708387555557a5b4886292346da6bb.view
/var/lib/couchdb/0.10.0/.chef_design/e3e1cc2873d481d95c621d836cb181e5.view
/var/lib/couchdb/0.10.0/.chef_design/af280ad217f6edca6276d1d1bcbc069d.view
/var/lib/couchdb/0.10.0/chef.couch
# enabling munin_update plugin on a munin server using opscode chef
# added to bottom of munin/recipes/server.rb
# https://github.com/opscode/cookbooks/blob/master/munin/recipes/server.rb
%w{ munin_update munin_stats }.each do |plugin|
link "#{plugin_config}/#{plugin}" do
to "#{plugin_dir}/#{plugin}"
notifies :restart, resources(:service => "munin-node")
end
end
# trigger this periodically to have munin detect new available plugins if available
execute "munin-configure" do
action :nothing
command "/usr/sbin/munin-node-configure --suggest --shell | /bin/sh"
notifies :restart, resources(:service => "munin-node")
end
btm@serenity:~$ gem list
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.3, 3.0.1)
actionpack (3.0.3, 3.0.1)
activemodel (3.0.3, 3.0.1)
activerecord (3.0.3, 3.0.1)
activeresource (3.0.3, 3.0.1)
# passing environment variables to apt-get with the chef execute resource
execute "install sudo-ldap with environment settings" do
command "apt-get -q -y install sudo-ldap"
action :run
environment ({
'SUDO_FORCE_REMOVE' => 'yes',
'DEBIAN_FRONTEND' => 'noninteractive'})
only_if "apt-cache policy sudo-ldap | grep '(none)'"
end
ubuntu@ip-10-244-46-116:~$ diff before after
2a3,6
> "placement_availability_zone",
> "us-east-1d"
> ],
> [
6a11,14
> "block_device_mapping_root",
> "/dev/sda1"
> ],
btm@btm-mbp-dev:~ $ rmadison nodejs -u ubuntu
nodejs | 0.1.97-1build1 | maverick/universe | source, amd64, i386
nodejs | 0.2.6-4ubuntu1 | natty/universe | source, amd64, i386
btm@btm-mbp-dev:~ $ rmadison nodejs -u debian
nodejs | 0.2.0-1 | wheezy | source, amd64, armel, i386
nodejs | 0.2.6-4 | sid | source, amd64, armel, i386