Don't push incoming to klecker
[mirror/dsa-puppet.git] / 3rdparty / modules / rabbitmq / manifests / init.pp
1 # Main rabbitmq class
2 class rabbitmq(
3   $admin_enable               = $rabbitmq::params::admin_enable,
4   $cluster_node_type          = $rabbitmq::params::cluster_node_type,
5   $cluster_nodes              = $rabbitmq::params::cluster_nodes,
6   $config                     = $rabbitmq::params::config,
7   $config_cluster             = $rabbitmq::params::config_cluster,
8   $config_path                = $rabbitmq::params::config_path,
9   $config_stomp               = $rabbitmq::params::config_stomp,
10   $default_user               = $rabbitmq::params::default_user,
11   $default_pass               = $rabbitmq::params::default_pass,
12   $delete_guest_user          = $rabbitmq::params::delete_guest_user,
13   $env_config                 = $rabbitmq::params::env_config,
14   $env_config_path            = $rabbitmq::params::env_config_path,
15   $erlang_cookie              = $rabbitmq::params::erlang_cookie,
16   $interface                  = $rabbitmq::params::interface,
17   $management_port            = $rabbitmq::params::management_port,
18   $node_ip_address            = $rabbitmq::params::node_ip_address,
19   $package_apt_pin            = $rabbitmq::params::package_apt_pin,
20   $package_ensure             = $rabbitmq::params::package_ensure,
21   $package_gpg_key            = $rabbitmq::params::package_gpg_key,
22   $package_name               = $rabbitmq::params::package_name,
23   $package_provider           = $rabbitmq::params::package_provider,
24   $package_source             = undef,
25   $repos_ensure               = $rabbitmq::params::repos_ensure,
26   $manage_repos               = $rabbitmq::params::manage_repos,
27   $plugin_dir                 = $rabbitmq::params::plugin_dir,
28   $rabbitmq_user              = $rabbitmq::params::rabbitmq_user,
29   $rabbitmq_group             = $rabbitmq::params::rabbitmq_group,
30   $rabbitmq_home              = $rabbitmq::params::rabbitmq_home,
31   $port                       = $rabbitmq::params::port,
32   $tcp_keepalive              = $rabbitmq::params::tcp_keepalive,
33   $service_ensure             = $rabbitmq::params::service_ensure,
34   $service_manage             = $rabbitmq::params::service_manage,
35   $service_name               = $rabbitmq::params::service_name,
36   $ssl                        = $rabbitmq::params::ssl,
37   $ssl_only                   = $rabbitmq::params::ssl_only,
38   $ssl_cacert                 = $rabbitmq::params::ssl_cacert,
39   $ssl_cert                   = $rabbitmq::params::ssl_cert,
40   $ssl_key                    = $rabbitmq::params::ssl_key,
41   $ssl_port                   = $rabbitmq::params::ssl_port,
42   $ssl_interface              = $rabbitmq::params::ssl_interface,
43   $ssl_management_port        = $rabbitmq::params::ssl_management_port,
44   $ssl_stomp_port             = $rabbitmq::params::ssl_stomp_port,
45   $ssl_verify                 = $rabbitmq::params::ssl_verify,
46   $ssl_fail_if_no_peer_cert   = $rabbitmq::params::ssl_fail_if_no_peer_cert,
47   $ssl_versions               = $rabbitmq::params::ssl_versions,
48   $ssl_ciphers                = $rabbitmq::params::ssl_ciphers,
49   $stomp_ensure               = $rabbitmq::params::stomp_ensure,
50   $ldap_auth                  = $rabbitmq::params::ldap_auth,
51   $ldap_server                = $rabbitmq::params::ldap_server,
52   $ldap_user_dn_pattern       = $rabbitmq::params::ldap_user_dn_pattern,
53   $ldap_other_bind            = $rabbitmq::params::ldap_other_bind,
54   $ldap_use_ssl               = $rabbitmq::params::ldap_use_ssl,
55   $ldap_port                  = $rabbitmq::params::ldap_port,
56   $ldap_log                   = $rabbitmq::params::ldap_log,
57   $ldap_config_variables      = $rabbitmq::params::ldap_config_variables,
58   $stomp_port                 = $rabbitmq::params::stomp_port,
59   $version                    = $rabbitmq::params::version,
60   $wipe_db_on_cookie_change   = $rabbitmq::params::wipe_db_on_cookie_change,
61   $cluster_partition_handling = $rabbitmq::params::cluster_partition_handling,
62   $file_limit                 = $rabbitmq::params::file_limit,
63   $environment_variables      = $rabbitmq::params::environment_variables,
64   $config_variables           = $rabbitmq::params::config_variables,
65   $config_kernel_variables    = $rabbitmq::params::config_kernel_variables,
66   $key_content                = undef,
67 ) inherits rabbitmq::params {
68
69   validate_bool($admin_enable)
70   # Validate install parameters.
71   validate_re($package_apt_pin, '^(|\d+)$')
72   validate_string($package_ensure)
73   validate_string($package_gpg_key)
74   validate_string($package_name)
75   validate_string($package_provider)
76   validate_bool($repos_ensure)
77   validate_re($version, '^\d+\.\d+\.\d+(-\d+)*$') # Allow 3 digits and optional -n postfix.
78   # Validate config parameters.
79   validate_re($cluster_node_type, '^(ram|disc|disk)$') # Both disc and disk are valid http://www.rabbitmq.com/clustering.html
80   validate_array($cluster_nodes)
81   validate_string($config)
82   validate_absolute_path($config_path)
83   validate_bool($config_cluster)
84   validate_bool($config_stomp)
85   validate_string($default_user)
86   validate_string($default_pass)
87   validate_bool($delete_guest_user)
88   validate_string($env_config)
89   validate_absolute_path($env_config_path)
90   validate_string($erlang_cookie)
91   if ! is_integer($management_port) {
92     validate_re($management_port, '\d+')
93   }
94   validate_string($node_ip_address)
95   validate_absolute_path($plugin_dir)
96   if ! is_integer($port) {
97     validate_re($port, ['\d+','UNSET'])
98   }
99   if ! is_integer($stomp_port) {
100     validate_re($stomp_port, '\d+')
101   }
102   validate_bool($wipe_db_on_cookie_change)
103   validate_bool($tcp_keepalive)
104   if ! is_integer($file_limit) {
105     validate_re($file_limit, '^(unlimited|infinity)$', '$file_limit must be an integer, \'unlimited\', or \'infinity\'.')
106   }
107   # Validate service parameters.
108   validate_re($service_ensure, '^(running|stopped)$')
109   validate_bool($service_manage)
110   validate_string($service_name)
111   validate_bool($ssl)
112   validate_bool($ssl_only)
113   validate_string($ssl_cacert)
114   validate_string($ssl_cert)
115   validate_string($ssl_key)
116   validate_array($ssl_ciphers)
117   if ! is_integer($ssl_port) {
118     validate_re($ssl_port, '\d+')
119   }
120   if ! is_integer($ssl_management_port) {
121     validate_re($ssl_management_port, '\d+')
122   }
123   if ! is_integer($ssl_stomp_port) {
124     validate_re($ssl_stomp_port, '\d+')
125   }
126   validate_bool($stomp_ensure)
127   validate_bool($ldap_auth)
128   validate_string($ldap_server)
129   validate_string($ldap_user_dn_pattern)
130   validate_string($ldap_other_bind)
131   validate_hash($ldap_config_variables)
132   validate_bool($ldap_use_ssl)
133   validate_re($ldap_port, '\d+')
134   validate_bool($ldap_log)
135   validate_hash($environment_variables)
136   validate_hash($config_variables)
137   validate_hash($config_kernel_variables)
138
139   if $ssl_only and ! $ssl {
140     fail('$ssl_only => true requires that $ssl => true')
141   }
142
143   if $config_stomp and $ssl_stomp_port and ! $ssl {
144     warning('$ssl_stomp_port requires that $ssl => true and will be ignored')
145   }
146
147   if $ssl_versions {
148     if $ssl {
149       validate_array($ssl_versions)
150     } else {
151       fail('$ssl_versions requires that $ssl => true')
152     }
153   }
154
155   # This needs to happen here instead of params.pp because
156   # $package_source needs to override the constructed value in params.pp
157   if $package_source { # $package_source was specified by user so use that one
158     $real_package_source = $package_source
159   # NOTE(bogdando) do not enforce the source value for yum provider #MODULES-1631
160   } elsif $package_provider != 'yum' {
161     # package_source was not specified, so construct it, unless the provider is 'yum'
162     case $::osfamily {
163       'RedHat', 'SUSE': {
164         $base_version   = regsubst($version,'^(.*)-\d$','\1')
165         $real_package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v${base_version}/rabbitmq-server-${version}.noarch.rpm"
166       }
167       default: { # Archlinux and Debian
168         $real_package_source = ''
169       }
170     }
171   } else { # for yum provider, use the source as is
172     $real_package_source = $package_source
173   }
174
175   include '::rabbitmq::install'
176   include '::rabbitmq::config'
177   include '::rabbitmq::service'
178   include '::rabbitmq::management'
179
180   if $manage_repos != undef {
181     warning('$manage_repos is now deprecated. Please use $repos_ensure instead')
182   }
183
184   if $manage_repos != false {
185     case $::osfamily {
186       'RedHat', 'SUSE':
187         { include '::rabbitmq::repo::rhel' }
188       'Debian': {
189         class { '::rabbitmq::repo::apt' :
190           key_source  => $package_gpg_key,
191           key_content => $key_content,
192         }
193       }
194       default:
195         { }
196     }
197   }
198
199   if $admin_enable and $service_manage {
200     include '::rabbitmq::install::rabbitmqadmin'
201
202     rabbitmq_plugin { 'rabbitmq_management':
203       ensure  => present,
204       require => Class['rabbitmq::install'],
205       notify  => Class['rabbitmq::service'],
206     }
207
208     Class['::rabbitmq::service'] -> Class['::rabbitmq::install::rabbitmqadmin']
209     Class['::rabbitmq::install::rabbitmqadmin'] -> Rabbitmq_exchange<| |>
210   }
211
212   if $stomp_ensure {
213     rabbitmq_plugin { 'rabbitmq_stomp':
214       ensure  => present,
215       require => Class['rabbitmq::install'],
216       notify  => Class['rabbitmq::service'],
217     }
218   }
219
220   if ($ldap_auth) {
221     rabbitmq_plugin { 'rabbitmq_auth_backend_ldap':
222       ensure  => present,
223       require => Class['rabbitmq::install'],
224       notify  => Class['rabbitmq::service'],
225     }
226   }
227
228   anchor { 'rabbitmq::begin': }
229   anchor { 'rabbitmq::end': }
230
231   Anchor['rabbitmq::begin'] -> Class['::rabbitmq::install']
232     -> Class['::rabbitmq::config'] ~> Class['::rabbitmq::service']
233     -> Class['::rabbitmq::management'] -> Anchor['rabbitmq::end']
234
235   # Make sure the various providers have their requirements in place.
236   Class['::rabbitmq::install'] -> Rabbitmq_plugin<| |>
237
238 }