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