Skip to content

Instantly share code, notes, and snippets.

View caryp's full-sized avatar

caryp

View GitHub Profile
#
# Cookbook Name:: repo_git
# Definition:: repo_git_pull
#
define :repo_git_pull, url => nil, branch => 'master', dest => nil, user => nil, cred => nil do
# add repository credentials
if params[:cred] != nil
#
# Cookbook Name:: dns
# Recipe:: default
#
## Set DNS for given id to the current address of this node
#
#dns "my.domain.id.com" do
# user "account_user_name"
# passwd "account_password"
# Configuring Apache Multi-Processing Module
case node[:platform]
when "centos","redhat","fedora","suse"
binary_to_use = @node[:apache][:binary]
if @node[:apache][:mpm] != 'prefork'
binary_to_use << ".worker"
end
template "centos_sysconfig_httpd" do
diff --git a/spec/ohai/plugins/ec2_spec.rb b/spec/ohai/plugins/ec2_spec.rb
index 8ffb1ef..ddd046e 100644
--- a/spec/ohai/plugins/ec2_spec.rb
+++ b/spec/ohai/plugins/ec2_spec.rb
@@ -51,6 +51,10 @@ describe Ohai::System, "plugin ec2" do
end
it "should recursively fetch all the ec2 metadata" do
+ IO.stub!(:select).and_return([[],[1],[]])
+ t = mock("connection")
Cloud Agnostic Attributes ¶
To avoid coding cloud specific attributes (like EC2's "public_ipv4") into recipes it would be nice to make available "cloud agnostic" attributes in the chef node. These attributes would be a collection of instance information that is common across all clouds (such as instance identifiers and public/private ip addresses). By abstracting these platform specific values and placing them in the chef node it will provide a uniform way for recipes to access instance information without adding 'if' or 'case' statement within the recipes.
Not only will this avoid clutter in the recipes, but it will also avoid a maintenance burden by placing cloud specific code in one place.
Some attributes immediately apparent are:
instance_id : an instance identifier assigned by the cloud provider. public_ip : the public facing IP address for the instance. private_ip : the private IP address for the instance. others??
naming suggestions ¶
my_action "example interface call" do
definition :my_bar2_action
out_dir "#{node[:foo][:out_dir]}"
end
my_action "example dynamic interface call" do
definition node[:foo][:impl]
out_dir "#{node[:foo][:out_dir]}"
end
diff --git a/agents/lib/instance/executable_sequence.rb b/agents/lib/instance/executable_sequence.rb
index bc511b0..ebb88bd 100644
--- a/agents/lib/instance/executable_sequence.rb
+++ b/agents/lib/instance/executable_sequence.rb
@@ -152,7 +152,7 @@ module RightScale
when :git
ssh_cmd = ssh_command(repo)
"#{ssh_cmd} git clone --quiet --depth 1 #{repo.url} #{cookbook_dir} 2>&1" +
- (repo.tag ? " && cd #{cookbook_dir} && #{ssh_cmd} git pull 2>&1 && git checkout #{repo.tag} 2>&1 && cd -" : '')
+ (repo.tag ? " && cd #{cookbook_dir} && #{ssh_cmd} git pull 2>&1 && git checkout -b #{repo.tag} origin/#{repo.tag} 2>&1 && cd -" : '')
def determine_node_name
run_ohai
unless @safe_name && @node_name
@node_name ||= @ohai[:fqdn] ? @ohai[:fqdn] : @ohai[:hostname]
@safe_name = @node_name.gsub(/\./, '_')
end
@node_name
end
attribute "pet/favorite",
:display_name => "Favorite Pet",
:description => "Choose either dog, cat, or monkey",
:options => ["dog", "cat", "monkey"],
:type => "select_one"
:default => "monkey"