17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/poolparty/plugins/haproxy.rb', line 17
def loaded(o={}, &block)
set_vars_from_options(cloud.dsl_options.reject{|k,v| [:enabled, :disabled].include?(v) }) if cloud
has_service(:name => "sysklogd")
has_package "haproxy"
has_variable("haproxy_name", :value => "#{(cloud ? cloud.name : name)}")
has_variable("listen_ports", :value => [ "8080" ], :namespace => "apache")
has_variable("ports_haproxy", :value => ([(port || Default.port)].flatten))
has_variable("forwarding_port", :value => (forwarding_port || Default.forwarding_port))
has_variable("proxy_mode", :value => (proxy_mode || Default.proxy_mode))
has_line_in_file(:line => "ENABLED=1", :file => "/etc/default/haproxy")
has_line_in_file({:line => "SYSLOGD=\"-r\"", :file => "/etc/default/syslogd"})
has_line_in_file({:line => "local0.* /var/log/haproxy.log", :file => "/etc/syslog.conf"}, {:notify => get_service("sysklogd")})
has_file '/var/log/haproxy.log' do
content ''
end
has_directory "/var/run/haproxy"
has_exec "reloadhaproxy",
:command => "/etc/init.d/haproxy reload",
:ensures => "nothing",
:requires => get_package("haproxy")
has_file "/etc/haproxy/haproxy.cfg" do
template "#{::File.dirname(__FILE__)}/../templates/haproxy.conf"
calls get_exec("reloadhaproxy")
end
has_service("haproxy") do
action [:start, :enable]
end
end
|