1 # == Define Resource Type: apache::balancer
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
10 # === Requirement/Dependencies:
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
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
23 # Hash, default empty. If given, each key-value pair will be used as a ProxySet
24 # line in the configuration.
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)
37 # Exporting the resource for a balancer member:
39 # apache::balancer { 'puppet00': }
41 define apache::balancer (
43 $collect_exported = true,
45 include ::apache::mod::proxy_balancer
47 $target = "${::apache::params::confd_dir}/balancer_${name}.conf"
53 notify => Class['Apache::Service'],
56 concat::fragment { "00-${name}-header":
60 content => "<Proxy balancer://${name}>\n",
63 if $collect_exported {
64 Apache::Balancermember <<| balancer_cluster == $name |>>
66 # else: the resources have been created and they introduced their
67 # concat fragments. We don't have to do anything about them.
69 concat::fragment { "01-${name}-proxyset":
73 content => inline_template("<% @proxy_set.keys.sort.each do |key| %> Proxyset <%= key %>=<%= @proxy_set[key] %>\n<% end %>"),
76 concat::fragment { "01-${name}-footer":
80 content => "</Proxy>\n",