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