28
|
1 |
# == Define Resource Type: apache::balancer |
|
2 |
# |
|
3 |
# This type will create an apache balancer cluster file inside the conf.d |
|
4 |
# directory. Each balancer cluster needs one or more balancer members (that can |
|
5 |
# be declared with the apache::balancermember defined resource type). Using |
|
6 |
# storeconfigs, you can export the apache::balancermember resources on all |
|
7 |
# balancer members, and then collect them on a single apache load balancer |
|
8 |
# server. |
|
9 |
# |
|
10 |
# === Requirement/Dependencies: |
|
11 |
# |
|
12 |
# Currently requires the puppetlabs/concat module on the Puppet Forge and uses |
|
13 |
# storeconfigs on the Puppet Master to export/collect resources from all |
|
14 |
# balancer members. |
|
15 |
# |
|
16 |
# === Parameters |
|
17 |
# |
|
18 |
# [*name*] |
|
19 |
# The namevar of the defined resource type is the balancer clusters name. |
|
20 |
# This name is also used in the name of the conf.d file |
|
21 |
# |
|
22 |
# [*proxy_set*] |
|
23 |
# Hash, default empty. If given, each key-value pair will be used as a ProxySet |
|
24 |
# line in the configuration. |
|
25 |
# |
|
26 |
# [*collect_exported*] |
|
27 |
# Boolean, default 'true'. True means 'collect exported @@balancermember |
|
28 |
# resources' (for the case when every balancermember node exports itself), |
|
29 |
# false means 'rely on the existing declared balancermember resources' (for the |
|
30 |
# case when you know the full set of balancermembers in advance and use |
|
31 |
# apache::balancermember with array arguments, which allows you to deploy |
|
32 |
# everything in 1 run) |
|
33 |
# |
|
34 |
# |
|
35 |
# === Examples |
|
36 |
# |
|
37 |
# Exporting the resource for a balancer member: |
|
38 |
# |
|
39 |
# apache::balancer { 'puppet00': } |
|
40 |
# |
|
41 |
define apache::balancer ( |
|
42 |
$proxy_set = {}, |
|
43 |
$collect_exported = true, |
|
44 |
) { |
|
45 |
include ::apache::mod::proxy_balancer |
|
46 |
|
|
47 |
$target = "${::apache::params::confd_dir}/balancer_${name}.conf" |
|
48 |
|
|
49 |
concat { $target: |
|
50 |
owner => '0', |
|
51 |
group => '0', |
|
52 |
mode => '0644', |
|
53 |
notify => Class['Apache::Service'], |
|
54 |
} |
|
55 |
|
|
56 |
concat::fragment { "00-${name}-header": |
|
57 |
ensure => present, |
|
58 |
target => $target, |
|
59 |
order => '01', |
|
60 |
content => "<Proxy balancer://${name}>\n", |
|
61 |
} |
|
62 |
|
|
63 |
if $collect_exported { |
|
64 |
Apache::Balancermember <<| balancer_cluster == $name |>> |
|
65 |
} |
|
66 |
# else: the resources have been created and they introduced their |
|
67 |
# concat fragments. We don't have to do anything about them. |
|
68 |
|
|
69 |
concat::fragment { "01-${name}-proxyset": |
|
70 |
ensure => present, |
|
71 |
target => $target, |
|
72 |
order => '19', |
|
73 |
content => inline_template("<% @proxy_set.keys.sort.each do |key| %> Proxyset <%= key %>=<%= @proxy_set[key] %>\n<% end %>"), |
|
74 |
} |
|
75 |
|
|
76 |
concat::fragment { "01-${name}-footer": |
|
77 |
ensure => present, |
|
78 |
target => $target, |
|
79 |
order => '20', |
|
80 |
content => "</Proxy>\n", |
|
81 |
} |
|
82 |
} |