Skip to content

Instantly share code, notes, and snippets.

View fujin's full-sized avatar

AJ Christensen fujin

  • Rotorua, New Zealand
View GitHub Profile
@fujin
fujin / router.rb
Created September 22, 2008 04:01 — forked from carllerche/router.rb
Merb.logger.info("Compiling routes...")
Merb::Router.prepare do |r|
# This deferred route allows permalinks to be handled, without a separate rack handler
match("/:permalink").defer_to do |request, params|
unless (article = Article.find_by_permalink(params[:permalink)).nil?
{:controller => "articles", :action => "show", :id => article.id}
end
end
# Admin namespace
@fujin
fujin / gist:15165
Created October 6, 2008 22:48 — forked from loe/gist:15164
define monit_file($ensure = 'absent') {
include monit
case $ensure {
'present': {
file {
"/etc/monit.d/${name}.run":
owner => "root", group => "root", mode => "0644",
replace => true,
source => "puppet:///monit/${name}.run",
notify => Service["monit"];
service "apache2" do
name value_for_platform(
[ "CentOS", "RedHat", "Fedora", "SuSE" ] => { "default" => "httpd" },
"Ubuntu" => { "8.04.1" => "apache2_lolz", "default" => "apache2" },
"Debian" => { "default" => "apache2" }
)
supports :restart => true
action :enable
end
@fujin
fujin / gist:52808
Created January 26, 2009 13:06 — forked from anonymous/gist:52807
node[:xen_vms].each do |name,vm|
execute "create-vm" do
command "xen-create-image --hostname #{name} --ip #{vm[:ip]} --size #{vm[:disk]} --memory #{vm[:memory]}"
creates "/etc/xen/#{name}.cfg"
notifies :run, resources("execute[start-vm")
end
execute "start-vm" do
command => "xm create #{name}.cfg"
unless "xm list | grep #{name}"
define :add_htpasswd_users do
params[:users].each do |auth|
execute "add_htpasswd_#{auth[:username]}" do
command "echo '#{auth[:username]}:#{auth[:password]}' >> #{params[:name]}"
not_if do
if File.exists?(params[:name])
File.open(params[:name]) do |password_file|
password_file.detect { |line| line =~ /#{auth[:username]}:#{auth[:password]}/ }
end
end
@fujin
fujin / gist:62289
Created February 11, 2009 21:47 — forked from jtimberman/gist:62263
resources in cookbook:
user "dnscache" do
uid 9997
case node[:platform]
when "ubuntu","debian"
gid "nogroup"
when "redhat", "centos"
gid "nobody"
else
@fujin
fujin / apt.rb
Created March 25, 2009 02:02 — forked from btm/apt.rb
#
# Cookbook Name:: apt
# Recipe:: default
#
# Copyright 2008, OpsCode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
--git a/chef-server-slice/Rakefile b/chef-server-slice/Rakefile
index 8cb5b22..64d958e 100644
--- a/chef-server-slice/Rakefile
+++ b/chef-server-slice/Rakefile
@@ -47,7 +47,7 @@ Rake::GemPackageTask.new(spec) do |pkg|
end
desc "Install the gem"
-task :install do
+task :install => :package do
# Divine Panda
service "foo" do
action :nothing
end
template "/etc/foo/config.conf" do
source "config.conf.erb"
action :create
notifies :restart, resources(:service => "foo")
end
@fujin
fujin / debug.txt
Created April 24, 2009 04:39 — forked from lachie/debug.txt
DEBUG: Processing user[lachie]
DEBUG: user[lachie] using Chef::Provider::User::Useradd
DEBUG: Setting user[lachie] comment to Lachie Cox
DEBUG: Managing the home directory for user[lachie]
DEBUG: Executing usermod -c 'Lachie Cox' -m lachie
DEBUG: Nothing to read on 'usermod -c 'Lachie Cox' -m lachie' STDOUT.
DEBUG: ---- Begin usermod -c 'Lachie Cox' -m lachie STDERR ----
DEBUG: Usage: usermod [options] LOGIN
Options: