Skip to content

Instantly share code, notes, and snippets.

View spheromak's full-sized avatar
🕵️‍♂️

Jesse Nelson spheromak

🕵️‍♂️
View GitHub Profile
# multi instance stuff
if @node[:postfix_multi]
# loop over all multi instances and asemble templates.
postconf = Hash.new
@node[:postfix_multi].each do |instance, settings|
# convert postfix config into hash to merge into
# mult-instance config
h = Hash.new
@node[:postfix].each do |k,v|
#!/usr/bin/ruby
require 'rubygems'
require 'erubis'
input = "
<% @conf.each do |k, v| -%>
<%= k %>=<%= v %>
<% end -%>
"
@spheromak
spheromak / gist:270991
Created January 7, 2010 04:33
route first pass
def generate_config
conf = Hash.new
case node[:platform]
when ("centos" || "redhat" || "fedora")
# walk the collection
@collection.each do |resource|
if resource.is_a? Chef::Resource::Route
# default to eth0
if resource.device
dev = resource.device
# minimal defaults for the main postfix setup
# by defaul postfix will be a null client setup
# to forward to sysmail only.
set[:postfix][:conf][:alias_database] = "hash:/etc/mail/aliases"
set[:postfix][:conf][:alias_maps] = "hash:/etc/mail/aliases"
set[:postfix][:conf][:html_directory] = "no"
set[:postfix][:conf][:inet_interfaces] = "localhost"
set[:postfix][:conf][:mail_owner] = "postfix"
set[:postfix][:conf][:mydestination] = nil
@spheromak
spheromak / template.erb
Created June 28, 2010 22:38
ldirectord dynamic chef example
package "ldirectord" do
action :install
end
lb = node[:heartbeat][:cluster]
# find all nodes that think they belong to a service
#
subscribes=Hash.new
search(:node, "milt_services:[* TO *]" ).each do |n|
# Plugin to extend the virtualization attributes in a Xen Host
require_plugin 'virtualization'
provides 'xenserver'
@xe_debug=false
require 'pp'
# run std popen4 and return array of lines
def xe_open(cmd)
a = Array.new
puts "execute: #{cmd}" if @xe_debug
#shef -z
... attrib stuff ...
/var/chef/cache/cookbooks/ohai/recipes/default.rb:20:in `from_file': undefined method `attribute?' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.6/lib/chef/cookbook_version.rb:316:in `load_recipe'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.6/lib/chef/mixin/language_include_recipe.rb:40:in `include_recipe'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.6/lib/chef/mixin/language_include_recipe.rb:27:in `each'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.6/lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.6/lib/chef/run_context.rb:93:in `load'
<uby/gems/1.8/gems/chef-0.9.6/lib/chef/provider/package/yum-dump.py | grep ^chef
chef,installed,0,0.9.6,3.el5,noarch
chef-common,available,0,0.8.10,1.el5,noarch
chef-common,available,0,0.8.10,2.el5,noarch
chef-server,available,0,0.8.10,1.el5,noarch
chef-server,available,0,0.8.10,2.el5,noarch
chef-server-webui,available,0,0.8.10,1.el5,noarch
chef-server-webui,available,0,0.8.10,2.el5,noarch
chef-solr,available,0,0.8.10,1.el5,noarch
chef-solr,available,0,0.8.10,2.el5,noarch
class Chef::Recipe
include Military::User
end
class Chef::Resource::User
include Military::User
end
wheel_members = group_members "wheel"
@spheromak
spheromak / hrmm
Created September 13, 2010 20:03
# shef -z
loading configuration: /etc/chef/client.rb
Session type: solo
Loading........Session type: solo
Loading...............Session type: solo
Loading.......................Session type: solo
Loading..............................Session type: solo
Loading.......................................Session type: solo