Ensure all Rabbit params are propagated to interested nodes.
[apex-tripleo-heat-templates.git] / puppet / manifests / overcloud_controller.pp
1 # Copyright 2014 Red Hat, Inc.
2 # All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16 if !str2bool(hiera('enable_package_install', 'false')) {
17   case $::osfamily {
18     'RedHat': {
19       Package { provider => 'norpm' } # provided by tripleo-puppet
20     }
21     default: {
22       warning('enable_package_install option not supported.')
23     }
24   }
25 }
26
27 if hiera('step') >= 1 {
28
29   include ::tripleo::loadbalancer
30
31 }
32
33 if hiera('step') >= 2 {
34
35   if count(hiera('ntp::servers')) > 0 {
36     include ::ntp
37   }
38
39   # TODO Galara
40   class { 'mysql::server':
41     override_options => {
42       'mysqld' => {
43         'bind-address' => hiera('controller_host')
44       }
45     }
46   }
47
48   # FIXME: this should only occur on the bootstrap host (ditto for db syncs)
49   # Create all the database schemas
50   # Example DSN format: mysql://user:password@host/dbname
51   $allowed_hosts = ['%',hiera('controller_host')]
52   $keystone_dsn = split(hiera('keystone::database_connection'), '[@:/?]')
53   class { 'keystone::db::mysql':
54     user          => $keystone_dsn[3],
55     password      => $keystone_dsn[4],
56     host          => $keystone_dsn[5],
57     dbname        => $keystone_dsn[6],
58     allowed_hosts => $allowed_hosts,
59   }
60   $glance_dsn = split(hiera('glance::api::database_connection'), '[@:/?]')
61   class { 'glance::db::mysql':
62     user          => $glance_dsn[3],
63     password      => $glance_dsn[4],
64     host          => $glance_dsn[5],
65     dbname        => $glance_dsn[6],
66     allowed_hosts => $allowed_hosts,
67   }
68   $nova_dsn = split(hiera('nova::database_connection'), '[@:/?]')
69   class { 'nova::db::mysql':
70     user          => $nova_dsn[3],
71     password      => $nova_dsn[4],
72     host          => $nova_dsn[5],
73     dbname        => $nova_dsn[6],
74     allowed_hosts => $allowed_hosts,
75   }
76   $neutron_dsn = split(hiera('neutron::server::database_connection'), '[@:/?]')
77   class { 'neutron::db::mysql':
78     user          => $neutron_dsn[3],
79     password      => $neutron_dsn[4],
80     host          => $neutron_dsn[5],
81     dbname        => $neutron_dsn[6],
82     allowed_hosts => $allowed_hosts,
83   }
84   $cinder_dsn = split(hiera('cinder::database_connection'), '[@:/?]')
85   class { 'cinder::db::mysql':
86     user          => $cinder_dsn[3],
87     password      => $cinder_dsn[4],
88     host          => $cinder_dsn[5],
89     dbname        => $cinder_dsn[6],
90     allowed_hosts => $allowed_hosts,
91   }
92   $heat_dsn = split(hiera('heat::database_connection'), '[@:/?]')
93   class { 'heat::db::mysql':
94     user          => $heat_dsn[3],
95     password      => $heat_dsn[4],
96     host          => $heat_dsn[5],
97     dbname        => $heat_dsn[6],
98     allowed_hosts => $allowed_hosts,
99   }
100   $ceilometer_dsn = split(hiera('ceilometer::db::database_connection'), '[@:/?]')
101   class { 'ceilometer::db::mysql':
102     user          => $ceilometer_dsn[3],
103     password      => $ceilometer_dsn[4],
104     host          => $ceilometer_dsn[5],
105     dbname        => $ceilometer_dsn[6],
106     allowed_hosts => $allowed_hosts,
107   }
108
109   if $::osfamily == 'RedHat' {
110     $rabbit_provider = 'yum'
111   } else {
112     $rabbit_provider = undef
113   }
114
115   Class['rabbitmq'] -> Rabbitmq_vhost <| |>
116   Class['rabbitmq'] -> Rabbitmq_user <| |>
117   Class['rabbitmq'] -> Rabbitmq_user_permissions <| |>
118
119   $rabbit_nodes = split(downcase(hiera('rabbit_nodes', $::hostname)), ',')
120   if count($rabbit_nodes) > 1 {
121     $rabbit_cluster = true
122   }
123   else {
124     $rabbit_cluster = false
125   }
126   class { 'rabbitmq':
127     package_provider => $rabbit_provider,
128     config_cluster   => $rabbit_cluster,
129     cluster_nodes    => $rabbit_nodes,
130     node_ip_address  => hiera('controller_host'),
131   }
132   rabbitmq_vhost { '/':
133     provider => 'rabbitmqctl',
134   }
135
136   # pre-install swift here so we can build rings
137   include ::swift
138
139   $cinder_enable_rbd_backend = hiera('cinder_enable_rbd_backend', false)
140   $enable_ceph = $cinder_enable_rbd_backend
141
142   if $enable_ceph {
143     class { 'ceph::profile::params':
144       mon_initial_members => downcase(hiera('ceph_mon_initial_members'))
145     }
146     include ::ceph::profile::mon
147   }
148
149   if $cinder_enable_rbd_backend {
150     ceph::key { 'client.openstack' :
151       secret  => hiera('ceph::profile::params::mon_key'),
152       cap_mon => hiera('ceph_openstack_default_cap_mon'),
153       cap_osd => hiera('ceph_openstack_default_cap_osd'),
154       user    => 'cinder',
155       inject  => 'true',
156     }
157   }
158
159 } #END STEP 2
160
161 if hiera('step') >= 3 {
162
163   include ::keystone
164
165   #TODO: need a cleanup-keystone-tokens.sh solution here
166   keystone_config {
167     'ec2/driver': value => 'keystone.contrib.ec2.backends.sql.Ec2';
168   }
169   file { [ '/etc/keystone/ssl', '/etc/keystone/ssl/certs', '/etc/keystone/ssl/private' ]:
170     ensure  => 'directory',
171     owner   => 'keystone',
172     group   => 'keystone',
173     require => Package['keystone'],
174   }
175   file { '/etc/keystone/ssl/certs/signing_cert.pem':
176     content => hiera('keystone_signing_certificate'),
177     owner   => 'keystone',
178     group   => 'keystone',
179     notify  => Service['keystone'],
180     require => File['/etc/keystone/ssl/certs'],
181   }
182   file { '/etc/keystone/ssl/private/signing_key.pem':
183     content => hiera('keystone_signing_key'),
184     owner   => 'keystone',
185     group   => 'keystone',
186     notify  => Service['keystone'],
187     require => File['/etc/keystone/ssl/private'],
188   }
189   file { '/etc/keystone/ssl/certs/ca.pem':
190     content => hiera('keystone_ca_certificate'),
191     owner   => 'keystone',
192     group   => 'keystone',
193     notify  => Service['keystone'],
194     require => File['/etc/keystone/ssl/certs'],
195   }
196
197   # TODO: notifications, scrubber, etc.
198   include ::glance::api
199   include ::glance::registry
200   include ::glance::backend::swift
201
202   class { 'nova':
203     glance_api_servers     => join([hiera('glance_protocol'), '://', hiera('controller_virtual_ip'), ':', hiera('glance_port')]),
204   }
205
206   include ::nova::api
207   include ::nova::cert
208   include ::nova::conductor
209   include ::nova::consoleauth
210   include ::nova::network::neutron
211   include ::nova::vncproxy
212   include ::nova::scheduler
213
214   include ::neutron
215   include ::neutron::server
216   include ::neutron::agents::dhcp
217   include ::neutron::agents::l3
218
219   file { '/etc/neutron/dnsmasq-neutron.conf':
220     content => hiera('neutron_dnsmasq_options'),
221     owner   => 'neutron',
222     group   => 'neutron',
223     notify  => Service['neutron-dhcp-service'],
224     require => Package['neutron'],
225   }
226
227   class { 'neutron::plugins::ml2':
228     flat_networks        => split(hiera('neutron_flat_networks'), ','),
229     tenant_network_types => [hiera('neutron_tenant_network_type')],
230     type_drivers         => [hiera('neutron_tenant_network_type')],
231   }
232
233   class { 'neutron::agents::ml2::ovs':
234     bridge_mappings  => split(hiera('neutron_bridge_mappings'), ','),
235     tunnel_types     => split(hiera('neutron_tunnel_types'), ','),
236   }
237
238   class { 'neutron::agents::metadata':
239     auth_url => join(['http://', hiera('controller_virtual_ip'), ':35357/v2.0']),
240   }
241
242   Service['neutron-server'] -> Service['neutron-dhcp-service']
243   Service['neutron-server'] -> Service['neutron-l3']
244   Service['neutron-server'] -> Service['neutron-ovs-agent-service']
245   Service['neutron-server'] -> Service['neutron-metadata']
246
247   include ::cinder
248   include ::cinder::api
249   include ::cinder::glance
250   include ::cinder::scheduler
251   include ::cinder::volume
252   class {'cinder::setup_test_volume':
253     size => join([hiera('cinder_lvm_loop_device_size'), 'M']),
254   }
255
256   $cinder_enable_iscsi = hiera('cinder_enable_iscsi_backend', true)
257   if $cinder_enable_iscsi {
258     $cinder_iscsi_backend = 'tripleo_iscsi'
259
260     cinder::backend::iscsi { $cinder_iscsi_backend :
261       iscsi_ip_address => hiera('cinder_iscsi_ip_address'),
262       iscsi_helper     => hiera('cinder_iscsi_helper'),
263     }
264   }
265
266   if $enable_ceph {
267
268     Ceph_pool {
269       pg_num  => hiera('ceph::profile::params::osd_pool_default_pg_num'),
270       pgp_num => hiera('ceph::profile::params::osd_pool_default_pgp_num'),
271       size    => hiera('ceph::profile::params::osd_pool_default_size'),
272     }
273
274     $ceph_pools = hiera('ceph_pools')
275     ceph::pool { $ceph_pools : }
276   }
277
278   if $cinder_enable_rbd_backend {
279     $cinder_rbd_backend = 'tripleo_ceph'
280
281     cinder_config {
282       "${cinder_rbd_backend}/host": value => 'hostgroup';
283     }
284
285     cinder::backend::rbd { $cinder_rbd_backend :
286       rbd_pool        => 'volumes',
287       rbd_user        => 'openstack',
288       rbd_secret_uuid => hiera('ceph::profile::params::fsid'),
289       require         => Ceph::Pool['volumes'],
290     }
291   }
292
293   $cinder_enabled_backends = concat(any2array($cinder_iscsi_backend), $cinder_rbd_backend)
294   class { '::cinder::backends' :
295     enabled_backends => $cinder_enabled_backends,
296   }
297
298   # swift proxy
299   include ::memcached
300   include ::swift::proxy
301   include ::swift::proxy::proxy_logging
302   include ::swift::proxy::healthcheck
303   include ::swift::proxy::cache
304   include ::swift::proxy::keystone
305   include ::swift::proxy::authtoken
306   include ::swift::proxy::staticweb
307   include ::swift::proxy::ceilometer
308   include ::swift::proxy::ratelimit
309   include ::swift::proxy::catch_errors
310   include ::swift::proxy::tempurl
311   include ::swift::proxy::formpost
312
313   # swift storage
314   class {'swift::storage::all':
315     mount_check => str2bool(hiera('swift_mount_check'))
316   }
317   if(!defined(File['/srv/node'])) {
318     file { '/srv/node':
319       ensure  => directory,
320       owner   => 'swift',
321       group   => 'swift',
322       require => Package['openstack-swift'],
323     }
324   }
325   $swift_components = ['account', 'container', 'object']
326   swift::storage::filter::recon { $swift_components : }
327   swift::storage::filter::healthcheck { $swift_components : }
328
329   # Ceilometer
330   include ::ceilometer
331   include ::ceilometer::api
332   include ::ceilometer::db
333   include ::ceilometer::agent::notification
334   include ::ceilometer::agent::central
335   include ::ceilometer::alarm::notifier
336   include ::ceilometer::alarm::evaluator
337   include ::ceilometer::expirer
338   include ::ceilometer::collector
339   class { 'ceilometer::agent::auth':
340     auth_url => join(['http://', hiera('controller_virtual_ip'), ':5000/v2.0']),
341   }
342
343   Cron <| title == 'ceilometer-expirer' |> { command => "sleep $((\$(od -A n -t d -N 3 /dev/urandom) % 86400)) && ${::ceilometer::params::expirer_command}" }
344
345   # Heat
346   include ::heat
347   include ::heat::api
348   include ::heat::api_cfn
349   include ::heat::api_cloudwatch
350   include ::heat::engine
351
352   $snmpd_user = hiera('snmpd_readonly_user_name')
353   snmp::snmpv3_user { $snmpd_user:
354     authtype => 'MD5',
355     authpass => hiera('snmpd_readonly_user_password'),
356   }
357   class { 'snmp':
358     agentaddress => ['udp:161','udp6:[::1]:161'],
359     snmpd_config => [ join(['rouser ', hiera('snmpd_readonly_user_name')]), 'proc  cron', 'includeAllDisks  10%', 'master agentx', 'trapsink localhost public', 'iquerySecName internalUser', 'rouser internalUser', 'defaultMonitors yes', 'linkUpDownNotifications yes' ],
360   }
361
362 } #END STEP 3