b98c3a40e8fb46710d8b15ed02664c85388891c6
[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 include tripleo::packages
17
18 if hiera('step') >= 1 {
19
20   create_resources(sysctl::value, hiera('sysctl_settings'), {})
21
22   $controller_node_ips = split(hiera('controller_node_ips'), ',')
23
24   class { '::tripleo::loadbalancer' :
25     controller_hosts => $controller_node_ips,
26     manage_vip       => true,
27   }
28
29 }
30
31 if hiera('step') >= 2 {
32
33   if count(hiera('ntp::servers')) > 0 {
34     include ::ntp
35   }
36
37   # MongoDB
38   if downcase(hiera('ceilometer_backend')) == 'mongodb' {
39     include ::mongodb::globals
40
41     include ::mongodb::server
42     $mongo_node_ips_with_port = suffix(hiera('mongo_node_ips'), ':27017')
43     $mongo_node_string = join($mongo_node_ips_with_port, ',')
44
45     $mongodb_replset = hiera('mongodb::server::replset')
46     $ceilometer_mongodb_conn_string = "mongodb://${mongo_node_string}/ceilometer?replicaSet=${mongodb_replset}"
47     if downcase(hiera('bootstrap_nodeid')) == $::hostname {
48       mongodb_replset { $mongodb_replset :
49         members => $mongo_node_ips_with_port,
50       }
51     }
52   }
53
54   # Redis
55   $redis_node_ips = hiera('redis_node_ips')
56   $redis_master_hostname = downcase(hiera('bootstrap_nodeid'))
57
58   if $redis_master_hostname == $::hostname {
59     $slaveof = undef
60   } else {
61     $slaveof = "${redis_master_hostname} 6379"
62   }
63   class {'::redis' :
64     slaveof => $slaveof,
65   }
66
67   if count($redis_node_ips) > 1 {
68     Class['::tripleo::redis_notification'] -> Service['redis-sentinel']
69     include ::redis::sentinel
70     include ::tripleo::redis_notification
71   }
72
73   if str2bool(hiera('enable_galera', 'true')) {
74     $mysql_config_file = '/etc/my.cnf.d/galera.cnf'
75   } else {
76     $mysql_config_file = '/etc/my.cnf.d/server.cnf'
77   }
78   # TODO Galara
79   class { 'mysql::server':
80     config_file => $mysql_config_file,
81     override_options => {
82       'mysqld' => {
83         'bind-address' => hiera('mysql_bind_host'),
84         'max_connections' => hiera('mysql_max_connections'),
85         'open_files_limit' => '-1',
86       },
87     }
88   }
89
90   # FIXME: this should only occur on the bootstrap host (ditto for db syncs)
91   # Create all the database schemas
92   include ::keystone::db::mysql
93   include ::glance::db::mysql
94   include ::nova::db::mysql
95   include ::neutron::db::mysql
96   include ::cinder::db::mysql
97   include ::heat::db::mysql
98   if downcase(hiera('ceilometer_backend')) == 'mysql' {
99     include ::ceilometer::db::mysql
100   }
101
102   $rabbit_nodes = hiera('rabbit_node_ips')
103   if count($rabbit_nodes) > 1 {
104     class { '::rabbitmq':
105       config_cluster          => true,
106       cluster_nodes           => $rabbit_nodes,
107       tcp_keepalive           => false,
108       config_kernel_variables => hiera('rabbitmq_kernel_variables'),
109       config_variables        => hiera('rabbitmq_config_variables'),
110       environment_variables   => hiera('rabbitmq_environment'),
111     }
112     rabbitmq_policy { 'ha-all@/':
113       pattern    => '^(?!amq\.).*',
114       definition => {
115         'ha-mode' => 'all',
116       },
117     }
118   } else {
119     include ::rabbitmq
120   }
121
122   # pre-install swift here so we can build rings
123   include ::swift
124
125   $enable_ceph = hiera('ceph_storage_count', 0) > 0
126
127   if $enable_ceph {
128     class { 'ceph::profile::params':
129       mon_initial_members => downcase(hiera('ceph_mon_initial_members'))
130     }
131     include ::ceph::profile::mon
132   }
133
134   if str2bool(hiera('enable_ceph_storage', 'false')) {
135     if str2bool(hiera('ceph_osd_selinux_permissive', true)) {
136       exec { 'set selinux to permissive on boot':
137         command => "sed -ie 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config",
138         onlyif  => "test -f /etc/selinux/config && ! grep '^SELINUX=permissive' /etc/selinux/config",
139         path    => ["/usr/bin", "/usr/sbin"],
140       }
141
142       exec { 'set selinux to permissive':
143         command => "setenforce 0",
144         onlyif  => "which setenforce && getenforce | grep -i 'enforcing'",
145         path    => ["/usr/bin", "/usr/sbin"],
146       } -> Class['ceph::profile::osd']
147     }
148
149     include ::ceph::profile::osd
150   }
151
152   if str2bool(hiera('enable_external_ceph', 'false')) {
153     include ::ceph::profile::client
154   }
155
156 } #END STEP 2
157
158 if hiera('step') >= 3 {
159
160   include ::keystone
161
162   #TODO: need a cleanup-keystone-tokens.sh solution here
163   keystone_config {
164     'ec2/driver': value => 'keystone.contrib.ec2.backends.sql.Ec2';
165   }
166   file { [ '/etc/keystone/ssl', '/etc/keystone/ssl/certs', '/etc/keystone/ssl/private' ]:
167     ensure  => 'directory',
168     owner   => 'keystone',
169     group   => 'keystone',
170     require => Package['keystone'],
171   }
172   file { '/etc/keystone/ssl/certs/signing_cert.pem':
173     content => hiera('keystone_signing_certificate'),
174     owner   => 'keystone',
175     group   => 'keystone',
176     notify  => Service['keystone'],
177     require => File['/etc/keystone/ssl/certs'],
178   }
179   file { '/etc/keystone/ssl/private/signing_key.pem':
180     content => hiera('keystone_signing_key'),
181     owner   => 'keystone',
182     group   => 'keystone',
183     notify  => Service['keystone'],
184     require => File['/etc/keystone/ssl/private'],
185   }
186   file { '/etc/keystone/ssl/certs/ca.pem':
187     content => hiera('keystone_ca_certificate'),
188     owner   => 'keystone',
189     group   => 'keystone',
190     notify  => Service['keystone'],
191     require => File['/etc/keystone/ssl/certs'],
192   }
193
194   $glance_backend = downcase(hiera('glance_backend', 'swift'))
195   case $glance_backend {
196       swift: { $backend_store = 'glance.store.swift.Store' }
197       file: { $backend_store = 'glance.store.filesystem.Store' }
198       rbd: { $backend_store = 'glance.store.rbd.Store' }
199       default: { fail('Unrecognized glance_backend parameter.') }
200   }
201   $http_store = ['glance.store.http.Store']
202   $glance_store = concat($http_store, $backend_store)
203
204   # TODO: notifications, scrubber, etc.
205   include ::glance
206   class { 'glance::api':
207     known_stores => $glance_store
208   }
209   include ::glance::registry
210   include join(['::glance::backend::', $glance_backend])
211
212   class { '::nova' :
213     memcached_servers => suffix(hiera('memcache_node_ips'), ':11211'),
214   }
215   include ::nova::config
216   include ::nova::api
217   include ::nova::cert
218   include ::nova::conductor
219   include ::nova::consoleauth
220   include ::nova::network::neutron
221   include ::nova::vncproxy
222   include ::nova::scheduler
223   include ::nova::scheduler::filter
224
225   include ::neutron
226   include ::neutron::server
227   include ::neutron::agents::l3
228   include ::neutron::agents::dhcp
229   include ::neutron::agents::metadata
230
231   file { '/etc/neutron/dnsmasq-neutron.conf':
232     content => hiera('neutron_dnsmasq_options'),
233     owner   => 'neutron',
234     group   => 'neutron',
235     notify  => Service['neutron-dhcp-service'],
236     require => Package['neutron'],
237   }
238
239   class { 'neutron::plugins::ml2':
240     flat_networks => split(hiera('neutron_flat_networks'), ','),
241     tenant_network_types => [hiera('neutron_tenant_network_type')],
242     mechanism_drivers   => [hiera('neutron_mechanism_drivers')],
243   }
244   class { 'neutron::agents::ml2::ovs':
245     bridge_mappings => split(hiera('neutron_bridge_mappings'), ','),
246     tunnel_types => split(hiera('neutron_tunnel_types'), ','),
247   }
248
249   if 'cisco_ucsm' in hiera('neutron_mechanism_drivers') {
250     include ::neutron::plugins::ml2::cisco::ucsm
251   }
252   if 'cisco_nexus' in hiera('neutron_mechanism_drivers') {
253     include ::neutron::plugins::ml2::cisco::nexus
254     include ::neutron::plugins::ml2::cisco::type_nexus_vxlan
255   }
256
257   Service['neutron-server'] -> Service['neutron-dhcp-service']
258   Service['neutron-server'] -> Service['neutron-l3']
259   Service['neutron-server'] -> Service['neutron-ovs-agent-service']
260   Service['neutron-server'] -> Service['neutron-metadata']
261
262   include ::cinder
263   include ::cinder::api
264   include ::cinder::glance
265   include ::cinder::scheduler
266   include ::cinder::volume
267   class {'cinder::setup_test_volume':
268     size => join([hiera('cinder_lvm_loop_device_size'), 'M']),
269   }
270
271   $cinder_enable_iscsi = hiera('cinder_enable_iscsi_backend', true)
272   if $cinder_enable_iscsi {
273     $cinder_iscsi_backend = 'tripleo_iscsi'
274
275     cinder::backend::iscsi { $cinder_iscsi_backend :
276       iscsi_ip_address => hiera('cinder_iscsi_ip_address'),
277       iscsi_helper     => hiera('cinder_iscsi_helper'),
278     }
279   }
280
281   if $enable_ceph {
282
283     Ceph_pool {
284       pg_num  => hiera('ceph::profile::params::osd_pool_default_pg_num'),
285       pgp_num => hiera('ceph::profile::params::osd_pool_default_pgp_num'),
286       size    => hiera('ceph::profile::params::osd_pool_default_size'),
287     }
288
289     $ceph_pools = hiera('ceph_pools')
290     ceph::pool { $ceph_pools : }
291
292     $cinder_pool_requires = [Ceph::Pool['volumes']]
293
294   } else {
295     $cinder_pool_requires = []
296   }
297
298   if hiera('cinder_enable_rbd_backend', false) {
299     $cinder_rbd_backend = 'tripleo_ceph'
300
301     cinder::backend::rbd { $cinder_rbd_backend :
302       rbd_pool        => 'volumes',
303       rbd_user        => 'openstack',
304       rbd_secret_uuid => hiera('ceph::profile::params::fsid'),
305       require         => $cinder_pool_requires,
306     }
307   }
308
309   if hiera('cinder_enable_netapp_backend', false) {
310     $cinder_netapp_backend = hiera('cinder::backend::netapp::title')
311
312     cinder_config {
313       "${cinder_netapp_backend}/host": value => 'hostgroup';
314     }
315
316     if hiera('cinder::backend::netapp::nfs_shares', undef) {
317       $cinder_netapp_nfs_shares = split(hiera('cinder::backend::netapp::nfs_shares', undef), ',')
318     }
319
320     cinder::backend::netapp { $cinder_netapp_backend :
321       netapp_login                 => hiera('cinder::backend::netapp::netapp_login', undef),
322       netapp_password              => hiera('cinder::backend::netapp::netapp_password', undef),
323       netapp_server_hostname       => hiera('cinder::backend::netapp::netapp_server_hostname', undef),
324       netapp_server_port           => hiera('cinder::backend::netapp::netapp_server_port', undef),
325       netapp_size_multiplier       => hiera('cinder::backend::netapp::netapp_size_multiplier', undef),
326       netapp_storage_family        => hiera('cinder::backend::netapp::netapp_storage_family', undef),
327       netapp_storage_protocol      => hiera('cinder::backend::netapp::netapp_storage_protocol', undef),
328       netapp_transport_type        => hiera('cinder::backend::netapp::netapp_transport_type', undef),
329       netapp_vfiler                => hiera('cinder::backend::netapp::netapp_vfiler', undef),
330       netapp_volume_list           => hiera('cinder::backend::netapp::netapp_volume_list', undef),
331       netapp_vserver               => hiera('cinder::backend::netapp::netapp_vserver', undef),
332       netapp_partner_backend_name  => hiera('cinder::backend::netapp::netapp_partner_backend_name', undef),
333       nfs_shares                   => $cinder_netapp_nfs_shares,
334       nfs_shares_config            => hiera('cinder::backend::netapp::nfs_shares_config', undef),
335       netapp_copyoffload_tool_path => hiera('cinder::backend::netapp::netapp_copyoffload_tool_path', undef),
336       netapp_controller_ips        => hiera('cinder::backend::netapp::netapp_controller_ips', undef),
337       netapp_sa_password           => hiera('cinder::backend::netapp::netapp_sa_password', undef),
338       netapp_storage_pools         => hiera('cinder::backend::netapp::netapp_storage_pools', undef),
339       netapp_eseries_host_type     => hiera('cinder::backend::netapp::netapp_eseries_host_type', undef),
340       netapp_webservice_path       => hiera('cinder::backend::netapp::netapp_webservice_path', undef),
341     }
342   }
343
344   if hiera('cinder_enable_nfs_backend', false) {
345     $cinder_nfs_backend = 'tripleo_nfs'
346
347     if ($::selinux != "false") {
348       selboolean { 'virt_use_nfs':
349           value => on,
350           persistent => true,
351       } -> Package['nfs-utils']
352     }
353
354     package {'nfs-utils': } ->
355     cinder::backend::nfs { $cinder_nfs_backend :
356       nfs_servers         => hiera('cinder_nfs_servers'),
357       nfs_mount_options   => hiera('cinder_nfs_mount_options'),
358       nfs_shares_config   => '/etc/cinder/shares-nfs.conf',
359     }
360   }
361
362   $cinder_enabled_backends = delete_undef_values([$cinder_iscsi_backend, $cinder_rbd_backend, $cinder_netapp_backend, $cinder_nfs_backend])
363   class { '::cinder::backends' :
364     enabled_backends => $cinder_enabled_backends,
365   }
366
367   # swift proxy
368   include ::memcached
369   include ::swift::proxy
370   include ::swift::proxy::proxy_logging
371   include ::swift::proxy::healthcheck
372   include ::swift::proxy::cache
373   include ::swift::proxy::keystone
374   include ::swift::proxy::authtoken
375   include ::swift::proxy::staticweb
376   include ::swift::proxy::ratelimit
377   include ::swift::proxy::catch_errors
378   include ::swift::proxy::tempurl
379   include ::swift::proxy::formpost
380
381   # swift storage
382   if str2bool(hiera('enable_swift_storage', 'true')) {
383     class {'swift::storage::all':
384       mount_check => str2bool(hiera('swift_mount_check'))
385     }
386     if(!defined(File['/srv/node'])) {
387       file { '/srv/node':
388         ensure  => directory,
389         owner   => 'swift',
390         group   => 'swift',
391         require => Package['openstack-swift'],
392       }
393     }
394     $swift_components = ['account', 'container', 'object']
395     swift::storage::filter::recon { $swift_components : }
396     swift::storage::filter::healthcheck { $swift_components : }
397   }
398
399   # Ceilometer
400   $ceilometer_backend = downcase(hiera('ceilometer_backend'))
401   case $ceilometer_backend {
402     /mysql/ : {
403       $ceilometer_database_connection = hiera('ceilometer_mysql_conn_string')
404     }
405     default : {
406       $ceilometer_database_connection = $ceilometer_mongodb_conn_string
407     }
408   }
409   include ::ceilometer
410   include ::ceilometer::api
411   include ::ceilometer::agent::notification
412   include ::ceilometer::agent::central
413   include ::ceilometer::alarm::notifier
414   include ::ceilometer::alarm::evaluator
415   include ::ceilometer::expirer
416   include ::ceilometer::collector
417   include ceilometer::agent::auth
418   class { '::ceilometer::db' :
419     database_connection => $ceilometer_database_connection,
420   }
421
422   Cron <| title == 'ceilometer-expirer' |> { command => "sleep $((\$(od -A n -t d -N 3 /dev/urandom) % 86400)) && ${::ceilometer::params::expirer_command}" }
423
424   # Heat
425   include ::heat
426   include ::heat::api
427   include ::heat::api_cfn
428   include ::heat::api_cloudwatch
429   include ::heat::engine
430
431   # Horizon
432   $vhost_params = { add_listen => false }
433   class { 'horizon':
434     cache_server_ip    => hiera('memcache_node_ips', '127.0.0.1'),
435     vhost_extra_params => $vhost_params,
436   }
437
438   $snmpd_user = hiera('snmpd_readonly_user_name')
439   snmp::snmpv3_user { $snmpd_user:
440     authtype => 'MD5',
441     authpass => hiera('snmpd_readonly_user_password'),
442   }
443   class { 'snmp':
444     agentaddress => ['udp:161','udp6:[::1]:161'],
445     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' ],
446   }
447
448   hiera_include('controller_classes')
449
450 } #END STEP 3
451
452 if hiera('step') >= 4 {
453   include ::keystone::cron::token_flush
454 } #END STEP 4