Created
October 27, 2010 14:10
-
-
Save schisamo/649100 to your computer and use it in GitHub Desktop.
file edits for "Knife Pro Tips" webex: http://opscode.com/blog/2010/10/21/webcast-recording-knife-pro-tips/
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
# | |
# Cookbook Name:: haproxy | |
# Recipe:: default | |
# | |
# Copyright 2009, 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 | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
package "haproxy" do | |
action :install | |
end | |
template "/etc/default/haproxy" do | |
source "haproxy-default.erb" | |
owner "root" | |
group "root" | |
mode 0644 | |
end | |
service "haproxy" do | |
supports :restart => true, :status => true, :reload => true | |
action [:enable, :start] | |
end | |
pool_members = search(:node, "role:#{node[:haproxy][:pool_role]}") || [] | |
template "/etc/haproxy/haproxy.cfg" do | |
source "haproxy.cfg.erb" | |
owner "root" | |
group "root" | |
mode 0644 | |
variables :pool_members => pool_members | |
notifies :restart, resources(:service => "haproxy") | |
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
global | |
log 127.0.0.1 local0 | |
log 127.0.0.1 local1 notice | |
#log loghost local0 info | |
maxconn 4096 | |
#debug | |
#quiet | |
user haproxy | |
group haproxy | |
defaults | |
log global | |
mode http | |
option httplog | |
option dontlognull | |
retries 3 | |
redispatch | |
maxconn 2000 | |
contimeout 5000 | |
clitimeout 50000 | |
srvtimeout 50000 | |
# Set up application listeners here. | |
listen application 0.0.0.0:80 | |
balance roundrobin | |
<% @pool_members.each do |member| %> | |
<% server_ip = member.has_key?("ec2") ? member.ec2.public_ipv4 : member.ipaddress %> | |
server <%= member.hostname %> <%= server_ip %>:80 weight 1 maxconn 1 check | |
<% end %> | |
listen admin 0.0.0.0:22002 | |
mode http | |
stats uri / |
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
maintainer "YOUR_COMPANY_NAME" | |
maintainer_email "YOUR_EMAIL" | |
license "All rights reserved" | |
description "Installs/Configures knife_fu" | |
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) | |
version "0.0.1" | |
depends 'apache2' |
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
# | |
# Cookbook Name:: knife_fu | |
# Recipe:: default | |
# | |
# Copyright 2010, Opscode, Inc.. | |
# | |
# All rights reserved - Do Not Redistribute | |
# | |
include_recipe "apache2" | |
template "/var/www/index.html" do | |
source "index.html.erb" | |
owner "root" | |
group "root" | |
mode "0644" | |
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
<html> | |
<head> | |
<title>Welcome to <%= node[:hostname]%></title> | |
</head> | |
<body> | |
Knife rocks...you have reached: | |
<ul> | |
<li><b>FQDN</b>: <%= node[:fqdn] %></li> | |
<li><b>Public FQDN</b>: <%= node[:ec2][:public_hostname]%></li> | |
<li><b>IP Address</b>: <%= node[:ipaddress] %></li> | |
<li><b>Public IP</b>: <%= node[:ec2][:public_ipv4] %></li> | |
<li><b>Platform</b>: <%= node[:platform] %></li> | |
<li><b>Plaform Version</b>: <%= node[:platform_version] %></li> | |
<li><b>Run List</b>: <%= node.run_list %></li> | |
</ul> | |
</body> | |
</html> |
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
name "lb" | |
description "load balancer" | |
override_attributes( | |
:haproxy => {:pool_role => "web"} | |
) | |
run_list( | |
"recipe[haproxy]" | |
) |
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
name "web" | |
description "simple web app" | |
run_list( | |
"recipe[knife_fu]" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment