summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Larizza <gary@puppetlabs.com>2012-07-08 21:52:20 -0700
committerGary Larizza <gary@puppetlabs.com>2012-07-08 21:52:20 -0700
commit802ba51113fae827cec858562c71953f4269e4d5 (patch)
tree13dba3ce794a59f4a05e13930eda76df129c86ae
parente75b807f8571cff4bae145dd4c37773fb16a694f (diff)
parentc409a0953552107f4ad4c6535392071980d9e33b (diff)
Merge pull request #10 from rtyler/chicken-dinner
Fixy faxy
-rw-r--r--Rakefile2
-rw-r--r--manifests/balancermember.pp2
-rw-r--r--manifests/config.pp7
-rw-r--r--manifests/init.pp17
-rw-r--r--spec/defines/balancermember_spec.rb43
-rw-r--r--templates/haproxy_balancermember.erb5
-rw-r--r--tests/init.pp32
7 files changed, 72 insertions, 36 deletions
diff --git a/Rakefile b/Rakefile
index c5e9594..aa737b9 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,5 +1,5 @@
require 'rake'
-
+require 'puppet-lint/tasks/puppet-lint'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
diff --git a/manifests/balancermember.pp b/manifests/balancermember.pp
index 50e90c0..29fb382 100644
--- a/manifests/balancermember.pp
+++ b/manifests/balancermember.pp
@@ -21,7 +21,7 @@
# fragment name.
#
# [*listening_service*]
-# The haproxy service's instance name (or, the title of the
+# The haproxy service's instance name (or, the title of the
# haproxy::config resource). This must match up with a declared
# haproxy::config resource.
#
diff --git a/manifests/config.pp b/manifests/config.pp
index fba4f33..5825dd0 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -51,7 +51,8 @@
# virtual_ip => $::ipaddress,
# virtual_ip_port => '18140',
# mode => 'tcp',
-# haproxy_config_options => {'option' => ['tcplog', 'ssl-hello-chk'], 'balance' => 'roundrobin'},
+# haproxy_config_options => {'option' => ['tcplog', 'ssl-hello-chk'],
+# 'balance' => 'roundrobin'},
# }
#
# === Authors
@@ -63,7 +64,9 @@ define haproxy::config (
$order = '20',
$virtual_ip = $::ipaddress,
$mode = 'tcp',
- $haproxy_config_options = {'option' => ['tcplog', 'ssl-hello-chk'], 'balance' => 'roundrobin'},
+ $haproxy_config_options = {'option' => ['tcplog',
+ 'ssl-hello-chk'],
+ 'balance' => 'roundrobin'},
) {
concat::fragment { "${name}_config_block":
order => $order,
diff --git a/manifests/init.pp b/manifests/init.pp
index a0f5265..8005aec 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -45,7 +45,12 @@
# 'stats' => 'enable',
# 'option' => 'redispatch',
# 'retries' => '3',
-# 'timeout' => ['http-request 10s', 'queue 1m', 'connect 10s', 'client 1m', 'server 1m', 'check 10s'],
+# 'timeout' => ['http-request 10s',
+# 'queue 1m',
+# 'connect 10s',
+# 'client 1m',
+# 'server 1m',
+# 'check 10s'],
# 'maxconn' => '8000'
# },
#
@@ -63,13 +68,13 @@ class haproxy (
include concat::setup
package { 'haproxy':
- ensure => $enable ? {
+ ensure => $enable ? {
true => present,
false => absent,
},
- name => 'haproxy',
+ name => 'haproxy',
}
-
+
if $enable {
concat { '/etc/haproxy/haproxy.cfg':
owner => '0',
@@ -95,11 +100,11 @@ class haproxy (
}
service { 'haproxy':
- ensure => $enable ? {
+ ensure => $enable ? {
true => running,
false => stopped,
},
- enable => $enable ? {
+ enable => $enable ? {
true => true,
false => false,
},
diff --git a/spec/defines/balancermember_spec.rb b/spec/defines/balancermember_spec.rb
index 75b761e..4566ca4 100644
--- a/spec/defines/balancermember_spec.rb
+++ b/spec/defines/balancermember_spec.rb
@@ -7,17 +7,36 @@ describe 'haproxy::balancermember' do
:hostname => 'dero'
}
end
- let(:params) do
- { :name => 'tyler',
- :listening_service => 'croy',
- :balancer_port => '18140',
- :balancermember_options => 'check'
- }
+
+ context 'with a single balancermember option' do
+ let(:params) do
+ { :name => 'tyler',
+ :listening_service => 'croy',
+ :balancer_port => '18140',
+ :balancermember_options => 'check'
+ }
+ end
+
+ it { should contain_concat__fragment('croy_balancermember_tyler').with(
+ 'order' => '20',
+ 'target' => '/etc/haproxy/haproxy.cfg',
+ 'content' => " server dero 1.1.1.1:18140 check\n"
+ ) }
end
- it { should contain_concat__fragment('croy_balancermember_tyler').with(
- 'order' => '20',
- 'target' => '/etc/haproxy/haproxy.cfg',
- 'content' => " server dero 1.1.1.1:18140 check \n"
- ) }
-end \ No newline at end of file
+ context 'with multiple balancermember options' do
+ let(:params) do
+ { :name => 'tyler',
+ :listening_service => 'croy',
+ :balancer_port => '18140',
+ :balancermember_options => ['check', 'close']
+ }
+ end
+
+ it { should contain_concat__fragment('croy_balancermember_tyler').with(
+ 'order' => '20',
+ 'target' => '/etc/haproxy/haproxy.cfg',
+ 'content' => " server dero 1.1.1.1:18140 check close\n"
+ ) }
+ end
+end
diff --git a/templates/haproxy_balancermember.erb b/templates/haproxy_balancermember.erb
index b739e11..f85137d 100644
--- a/templates/haproxy_balancermember.erb
+++ b/templates/haproxy_balancermember.erb
@@ -1 +1,4 @@
- server <%= server_name %> <%= balancer_ip %>:<%= balancer_port %> <% balancermember_options.each do |item| %> <%= item %> <% end %>
+ server <%= server_name %> <%= balancer_ip %>:<%= balancer_port %> <%
+ items = balancermember_options
+ items = [items] unless balancermember_options.instance_of? Array
+ items.each do |item| %> <%= item %><% end %>
diff --git a/tests/init.pp b/tests/init.pp
index 32c32c7..f27f809 100644
--- a/tests/init.pp
+++ b/tests/init.pp
@@ -1,7 +1,7 @@
# Declare haproxy base class with configuration options
class { 'haproxy':
- enable => true,
- haproxy_global_options => { 'log' => "${::ipaddress} local0",
+ enable => true,
+ haproxy_global_options => {'log' => "${::ipaddress} local0",
'chroot' => '/var/lib/haproxy',
'pidfile' => '/var/run/haproxy.pid',
'maxconn' => '4000',
@@ -10,14 +10,18 @@ class { 'haproxy':
'daemon' => '',
'stats' => 'socket /var/lib/haproxy/stats'
},
- haproxy_defaults_options => { 'log' => 'global',
- 'stats' => 'enable',
- 'option' => 'redispatch',
- 'retries' => '3',
- 'timeout' => ['http-request 10s', 'queue 1m', 'connect 10s', 'client 1m', 'server 1m', 'check 10s'],
- 'maxconn' => '8000'
- },
-
+ haproxy_defaults_options => {'log' => 'global',
+ 'stats' => 'enable',
+ 'option' => 'redispatch',
+ 'retries' => '3',
+ 'timeout' => ['http-request 10s',
+ 'queue 1m',
+ 'connect 10s',
+ 'client 1m',
+ 'server 1m',
+ 'check 10s'],
+ 'maxconn' => '8000'
+ },
}
# Export a balancermember server, note that the listening_service parameter
@@ -39,12 +43,14 @@ haproxy::config { 'puppet00':
order => '20',
virtual_ip => $::ipaddress,
virtual_ip_port => '18140',
- haproxy_config_options => { 'option' => ['tcplog', 'ssl-hello-chk'], 'balance' => 'roundrobin' },
+ haproxy_config_options => {
+ 'option' => ['tcplog', 'ssl-hello-chk'], 'balance' => 'roundrobin' },
}
haproxy::config { 'stats':
order => '30',
virtual_ip => '',
virtual_ip_port => '9090',
- haproxy_config_options => { 'mode' => 'http', 'stats' => ['uri /', 'auth puppet:puppet'] },
+ haproxy_config_options => { 'mode' => 'http',
+ 'stats' => ['uri /', 'auth puppet:puppet']
+ },
}
-