Created
December 5, 2011 04:55
-
-
Save agibralter/1432358 to your computer and use it in GitHub Desktop.
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
rs_tools 'rightscale_lbtools-0.13.6.tgz' | |
package 'haproxy' do | |
action :install | |
end | |
service 'haproxy' do | |
supports(:restart => true, :reload => true) | |
action [:enable] | |
end | |
directory '/home/haproxy' do | |
owner 'haproxy' | |
group 'haproxy' | |
mode '0755' | |
recursive true | |
action :create | |
end | |
template '/etc/default/haproxy' do | |
source 'default_haproxy.erb' | |
owner 'root' | |
notifies(:restart, resources(:service => 'haproxy')) | |
end | |
stats_uri = "#{node.lb_haproxy[:haproxy_stats_uri]}" | |
stats_user = "#{node.lb_haproxy[:haproxy_stats_user]}" | |
stats_password = "#{node.lb_haproxy[:haproxy_stats_password]}" | |
health_check_uri = "#{node.lb_haproxy[:health_check_uri]}" | |
stats_uri_line = "stats uri #{stats_uri}" | |
stats_auth_line = "stats auth #{stats_user}:#{stats_password}" | |
health_check_uri_line = | |
"option httpchk GET #{health_check_uri} HTTP/1.1\\r\\nHost:\\ localhost" | |
template node.lb_haproxy[:cfg_file] do | |
source 'haproxy_http.erb' | |
owner 'haproxy' | |
group 'haproxy' | |
mode '0400' | |
variables({ | |
:stats_uri_line => stats_uri_line, | |
:stats_auth_line => stats_auth_line, | |
:health_check_uri_line => health_check_uri_line, | |
:errors_dir => "#{node.app[:frontend_root]}/errors", | |
:applistener_name => node.lb_haproxy[:applistener_name], | |
:bind_address => node.lb_haproxy[:bind_address], | |
:bind_port => node.lb_haproxy[:bind_port] | |
}) | |
notifies(:restart, resources(:service => 'haproxy')) | |
end | |
right_link_tag "loadbalancer:lb=#{node.lb_haproxy[:applistener_name]}" | |
log 'RightScale LB installation and configuration complete' |
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
script = '/opt/rightscale/lb/bin/haproxy_config_server.rb' | |
args = '-a add -w' | |
args += " -l \"#{node.lb_haproxy[:applistener_name]}\"" | |
args += " -s \"#{node.remote_recipe[:backend_id]}\"" | |
args += " -t \"#{node.remote_recipe[:backend_ip]}:8000\"" | |
args += ' -e "inter 3000 rise 2 fall 3 maxconn 500"' | |
args += ' -k on' | |
cmd = "#{script} #{args}" | |
bash "running #{cmd}" do | |
code(cmd) | |
notifies(:reload, resources(:service => 'haproxy')) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment