Mercurial > repos > other > Puppet
annotate modules/apache/manifests/balancer.pp @ 319:6d719622c72f
Remove proxied port 25
SMTP can't be proxied (because it's unencrypted and you don't find
the target until part way into the conversation) so we don't need
a section for it.
We'll need to use Mythic Beast's "store-and-forward" mail servers
for IPv4 compatibility without SSL
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 29 Feb 2020 14:10:26 +0000 |
parents | d9352a684e62 |
children | b8d6ada284dd |
rev | line source |
---|---|
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
1 # @summary |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
2 # This type will create an apache balancer cluster file inside the conf.d |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
3 # directory. |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 # |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
5 # Each balancer cluster needs one or more balancer members (that can |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 # be declared with the apache::balancermember defined resource type). Using |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 # storeconfigs, you can export the apache::balancermember resources on all |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 # balancer members, and then collect them on a single apache load balancer |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 # server. |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 # |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
11 # @note |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
12 # Currently requires the puppetlabs/concat module on the Puppet Forge and uses |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
13 # storeconfigs on the Puppet Master to export/collect resources from all |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
14 # balancer members. |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 # |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
16 # @param name |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
17 # The namevar of the defined resource type is the balancer clusters name.<br /> |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
18 # This name is also used in the name of the conf.d file |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 # |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
20 # @param proxy_set |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
21 # Configures key-value pairs to be used as a ProxySet lines in the configuration. |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
22 # |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
23 # @param target |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
24 # The path to the file the balancer definition will be written in. |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 # |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
26 # @param collect_exported |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
27 # Determines whether to use exported resources.<br /> |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
28 # If you statically declare all of your backend servers, set this parameter to false to rely |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
29 # on existing, declared balancer member resources. Also, use apache::balancermember with array |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
30 # arguments.<br /> |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
31 # To dynamically declare backend servers via exported resources collected on a central node, |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
32 # set this parameter to true to collect the balancer member resources exported by the balancer |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
33 # member nodes.<br /> |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
34 # If you don't use exported resources, a single Puppet run configures all balancer members. If |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
35 # you use exported resources, Puppet has to run on the balanced nodes first, then run on the |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
36 # balancer. |
257
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
37 # |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
38 # @param options |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
39 # Specifies an array of [options](https://httpd.apache.org/docs/current/mod/mod_proxy.html#balancermember) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
40 # after the balancer URL, and accepts any key-value pairs available to `ProxyPass`. |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 # |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
42 # @example |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
43 # apache::balancer { 'puppet00': } |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 # |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 define apache::balancer ( |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 $proxy_set = {}, |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 $collect_exported = true, |
257
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
48 $target = undef, |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
49 $options = [], |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 ) { |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 include ::apache::mod::proxy_balancer |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 |
257
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
53 if versioncmp($apache::mod::proxy_balancer::apache_version, '2.4') >= 0 { |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
54 $lbmethod = $proxy_set['lbmethod'] ? { |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
55 undef => 'byrequests', |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
56 default => $proxy_set['lbmethod'], |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
57 } |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
58 ensure_resource('apache::mod', "lbmethod_${lbmethod}", { |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
59 'loadfile_name' => "proxy_balancer_lbmethod_${lbmethod}.load" |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
60 }) |
257
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
61 } |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 |
257
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
63 if $target { |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
64 $_target = $target |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
65 } else { |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
66 $_target = "${::apache::confd_dir}/balancer_${name}.conf" |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
67 } |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
68 |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
69 if !empty($options) { |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
70 $_options = " ${join($options, ' ')}" |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
71 } else { |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
72 $_options = '' |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
73 } |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
74 |
257
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
75 concat { "apache_balancer_${name}": |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 owner => '0', |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 group => '0', |
257
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
78 path => $_target, |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
79 mode => $::apache::file_mode, |
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
80 notify => Class['Apache::Service'], |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 } |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 concat::fragment { "00-${name}-header": |
257
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
84 target => "apache_balancer_${name}", |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 order => '01', |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
257
diff
changeset
|
86 content => "<Proxy balancer://${name}${_options}>\n", |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
87 } |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
88 |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
89 if $collect_exported { |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
90 Apache::Balancermember <<| balancer_cluster == $name |>> |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
91 } |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
92 # else: the resources have been created and they introduced their |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
93 # concat fragments. We don't have to do anything about them. |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
94 |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
95 concat::fragment { "01-${name}-proxyset": |
257
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
96 target => "apache_balancer_${name}", |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
97 order => '19', |
36
37675581a273
Update Puppet module for Apache (pulls in concat module)
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
98 content => inline_template("<% @proxy_set.keys.sort.each do |key| %> Proxyset <%= key %>=<%= @proxy_set[key] %>\n<% end %>"), |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
99 } |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
100 |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
101 concat::fragment { "01-${name}-footer": |
257
675c1cc61eaf
Update Apache module to get CentOS 8 support
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
102 target => "apache_balancer_${name}", |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
103 order => '20', |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
104 content => "</Proxy>\n", |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
105 } |
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
106 } |