1 # Copyright 2015 Red Hat, Inc.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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
21 if !str2bool(hiera('enable_package_install', 'false')) {
24 Package { provider => 'norpm' } # provided by tripleo-puppet
27 warning('enable_package_install option not supported.')
32 if $::hostname == downcase(hiera('bootstrap_nodeid')) {
33 $pacemaker_master = true
36 $pacemaker_master = false
40 # When to start and enable services which haven't been Pacemakerized
41 # FIXME: remove when we start all OpenStack services using Pacemaker
42 # (occurences of this variable will be gradually replaced with false)
43 $non_pcmk_start = hiera('step') >= 4
45 if hiera('step') >= 1 {
47 create_resources(sysctl::value, hiera('sysctl_settings'), {})
49 if count(hiera('ntp::servers')) > 0 {
53 $controller_node_ips = split(hiera('controller_node_ips'), ',')
54 $controller_node_names = split(downcase(hiera('controller_node_names')), ',')
55 class { '::tripleo::loadbalancer' :
56 controller_hosts => $controller_node_ips,
57 controller_hosts_names => $controller_node_names,
59 haproxy_service_manage => false,
62 $pacemaker_cluster_members = downcase(regsubst(hiera('controller_node_names'), ',', ' ', 'G'))
66 class { '::pacemaker':
67 hacluster_pwd => hiera('hacluster_pwd'),
69 class { '::pacemaker::corosync':
70 cluster_members => $pacemaker_cluster_members,
71 setup_cluster => $pacemaker_master,
73 class { '::pacemaker::stonith':
77 # Only configure RabbitMQ in this step, don't start it yet to
78 # avoid races where non-master nodes attempt to start without
79 # config (eg. binding on 0.0.0.0)
80 # The module ignores erlang_cookie if cluster_config is false
82 service_manage => false,
83 tcp_keepalive => false,
84 config_kernel_variables => hiera('rabbitmq_kernel_variables'),
85 config_variables => hiera('rabbitmq_config_variables'),
86 environment_variables => hiera('rabbitmq_environment'),
88 file { '/var/lib/rabbitmq/.erlang.cookie':
93 content => hiera('rabbitmq::erlang_cookie'),
98 include ::mongodb::globals
100 # FIXME: replace with service_manage => false on ::mongodb::server
101 # when this is merged: https://github.com/puppetlabs/pupp etlabs-mongodb/pull/198
102 class { '::mongodb::server' :
103 service_ensure => undef,
104 service_enable => false,
108 if str2bool(hiera('enable_galera', 'true')) {
109 $mysql_config_file = '/etc/my.cnf.d/galera.cnf'
111 $mysql_config_file = '/etc/my.cnf.d/server.cnf'
113 $galera_nodes = downcase(hiera('galera_node_names', $::hostname))
114 $galera_nodes_count = count(split($galera_nodes, ','))
118 'skip-name-resolve' => '1',
119 'binlog_format' => 'ROW',
120 'default-storage-engine' => 'innodb',
121 'innodb_autoinc_lock_mode' => '2',
122 'innodb_locks_unsafe_for_binlog'=> '1',
123 'query_cache_size' => '0',
124 'query_cache_type' => '0',
125 'bind-address' => hiera('controller_host'),
126 'max_connections' => '1024',
127 'open_files_limit' => '-1',
128 'wsrep_provider' => '/usr/lib64/galera/libgalera_smm.so',
129 'wsrep_cluster_name' => 'galera_cluster',
130 'wsrep_slave_threads' => '1',
131 'wsrep_certify_nonPK' => '1',
132 'wsrep_max_ws_rows' => '131072',
133 'wsrep_max_ws_size' => '1073741824',
134 'wsrep_debug' => '0',
135 'wsrep_convert_LOCK_to_trx' => '0',
136 'wsrep_retry_autocommit' => '1',
137 'wsrep_auto_increment_control' => '1',
138 'wsrep_drupal_282555_workaround'=> '0',
139 'wsrep_causal_reads' => '0',
140 'wsrep_notify_cmd' => '',
141 'wsrep_sst_method' => 'rsync',
145 class { '::mysql::server':
146 create_root_user => false,
147 create_root_my_cnf => false,
148 config_file => $mysql_config_file,
149 override_options => $mysqld_options,
150 service_manage => false,
155 if hiera('step') >= 2 {
157 if $pacemaker_master {
158 $control_vip = hiera('tripleo::loadbalancer::controller_virtual_ip')
159 pacemaker::resource::ip { 'control_vip':
160 ip_address => $control_vip,
162 $public_vip = hiera('tripleo::loadbalancer::public_virtual_ip')
163 pacemaker::resource::ip { 'public_vip':
164 ip_address => $public_vip,
166 pacemaker::resource::service { 'haproxy':
167 clone_params => true,
170 pacemaker::resource::ocf { 'rabbitmq':
171 ocf_agent_name => 'heartbeat:rabbitmq-cluster',
172 resource_params => 'set_policy=\'ha-all ^(?!amq\.).* {"ha-mode":"all"}\'',
173 clone_params => 'ordered=true interleave=true',
174 require => Class['::rabbitmq'],
177 if downcase(hiera('ceilometer_backend')) == 'mongodb' {
178 pacemaker::resource::service { $::mongodb::params::service_name :
179 op_params => 'start timeout=120s',
180 clone_params => true,
181 require => Class['::mongodb::server'],
182 before => Exec['mongodb-ready'],
184 # NOTE (spredzy) : The replset can only be run
185 # once all the nodes have joined the cluster.
186 $mongo_node_ips = split(hiera('mongo_node_ips'), ',')
187 $mongo_node_ips_with_port = suffix($mongo_node_ips, ':27017')
188 $mongo_node_string = join($mongo_node_ips_with_port, ',')
189 $mongodb_replset = hiera('mongodb::server::replset')
190 $mongodb_cluster_ready_command = join(suffix(prefix($mongo_node_ips, '/bin/nc -w1 '), ' 27017 < /dev/null'), ' && ')
191 exec { 'mongodb-ready' :
192 command => $mongodb_cluster_ready_command,
197 mongodb_replset { $mongodb_replset :
198 members => $mongo_node_ips_with_port,
199 require => Exec['mongodb-ready'],
203 pacemaker::resource::ocf { 'galera' :
204 ocf_agent_name => 'heartbeat:galera',
205 op_params => 'promote timeout=300s on-fail=block --master',
206 meta_params => "master-max=${galera_nodes_count} ordered=true",
207 resource_params => "additional_parameters='--open-files-limit=16384' enable_creation=true wsrep_cluster_address='gcomm://${galera_nodes}'",
208 require => Class['::mysql::server'],
209 before => Exec['galera-ready'],
211 mysql_user { 'clustercheckuser@localhost' :
212 password_hash => mysql_password($clustercheck_password),
213 require => Exec['galera-ready'],
218 $redis_node_ips = split(hiera('redis_node_ips'), ',')
219 $redis_master_hostname = downcase(hiera('bootstrap_nodeid'))
221 if $redis_master_hostname == $::hostname {
224 $slaveof = "${redis_master_hostname} 6379"
230 if count($redis_node_ips) > 1 {
231 Class['::tripleo::redis_notification'] -> Service['redis-sentinel']
232 include ::redis::sentinel
233 class {'::tripleo::redis_notification' :
234 haproxy_monitor_ip => hiera('tripleo::loadbalancer::controller_virtual_ip'),
238 exec { 'galera-ready' :
239 command => '/usr/bin/clustercheck >/dev/null',
243 environment => ["AVAILABLE_WHEN_READONLY=0"],
244 require => File['/etc/sysconfig/clustercheck'],
247 file { '/etc/sysconfig/clustercheck' :
249 content => "MYSQL_USERNAME=root\n
251 MYSQL_HOST=localhost\n",
254 xinetd::service { 'galera-monitor' :
256 server => '/usr/bin/clustercheck',
257 per_source => 'UNLIMITED',
258 log_on_success => '',
259 log_on_failure => 'HOST',
261 service_type => 'UNLISTED',
264 require => File['/etc/sysconfig/clustercheck'],
267 # Create all the database schemas
268 # Example DSN format: mysql://user:password@host/dbname
270 $allowed_hosts = ['%',hiera('controller_host')]
271 $keystone_dsn = split(hiera('keystone::database_connection'), '[@:/?]')
272 class { 'keystone::db::mysql':
273 user => $keystone_dsn[3],
274 password => $keystone_dsn[4],
275 host => $keystone_dsn[5],
276 dbname => $keystone_dsn[6],
277 allowed_hosts => $allowed_hosts,
278 require => Exec['galera-ready'],
280 $glance_dsn = split(hiera('glance::api::database_connection'), '[@:/?]')
281 class { 'glance::db::mysql':
282 user => $glance_dsn[3],
283 password => $glance_dsn[4],
284 host => $glance_dsn[5],
285 dbname => $glance_dsn[6],
286 allowed_hosts => $allowed_hosts,
287 require => Exec['galera-ready'],
289 $nova_dsn = split(hiera('nova::database_connection'), '[@:/?]')
290 class { 'nova::db::mysql':
291 user => $nova_dsn[3],
292 password => $nova_dsn[4],
293 host => $nova_dsn[5],
294 dbname => $nova_dsn[6],
295 allowed_hosts => $allowed_hosts,
296 require => Exec['galera-ready'],
298 $neutron_dsn = split(hiera('neutron::server::database_connection'), '[@:/?]')
299 class { 'neutron::db::mysql':
300 user => $neutron_dsn[3],
301 password => $neutron_dsn[4],
302 host => $neutron_dsn[5],
303 dbname => $neutron_dsn[6],
304 allowed_hosts => $allowed_hosts,
305 require => Exec['galera-ready'],
307 $cinder_dsn = split(hiera('cinder::database_connection'), '[@:/?]')
308 class { 'cinder::db::mysql':
309 user => $cinder_dsn[3],
310 password => $cinder_dsn[4],
311 host => $cinder_dsn[5],
312 dbname => $cinder_dsn[6],
313 allowed_hosts => $allowed_hosts,
314 require => Exec['galera-ready'],
316 $heat_dsn = split(hiera('heat::database_connection'), '[@:/?]')
317 class { 'heat::db::mysql':
318 user => $heat_dsn[3],
319 password => $heat_dsn[4],
320 host => $heat_dsn[5],
321 dbname => $heat_dsn[6],
322 allowed_hosts => $allowed_hosts,
323 require => Exec['galera-ready'],
325 if downcase(hiera('ceilometer_backend')) == 'mysql' {
326 $ceilometer_dsn = split(hiera('ceilometer_mysql_conn_string'), '[@:/?]')
327 class { 'ceilometer::db::mysql':
328 user => $ceilometer_dsn[3],
329 password => $ceilometer_dsn[4],
330 host => $ceilometer_dsn[5],
331 dbname => $ceilometer_dsn[6],
332 allowed_hosts => $allowed_hosts,
333 require => Exec['galera-ready'],
338 # pre-install swift here so we can build rings
342 $cinder_enable_rbd_backend = hiera('cinder_enable_rbd_backend', false)
343 $enable_ceph = $cinder_enable_rbd_backend
346 class { 'ceph::profile::params':
347 mon_initial_members => downcase(hiera('ceph_mon_initial_members'))
349 include ::ceph::profile::mon
352 if str2bool(hiera('enable_ceph_storage', 'false')) {
353 include ::ceph::profile::client
354 include ::ceph::profile::osd
362 if hiera('step') >= 3 {
364 class { '::keystone':
366 manage_service => $non_pcmk_start,
367 enabled => $non_pcmk_start,
370 #TODO: need a cleanup-keystone-tokens.sh solution here
372 'ec2/driver': value => 'keystone.contrib.ec2.backends.sql.Ec2';
374 file { [ '/etc/keystone/ssl', '/etc/keystone/ssl/certs', '/etc/keystone/ssl/private' ]:
375 ensure => 'directory',
378 require => Package['keystone'],
380 file { '/etc/keystone/ssl/certs/signing_cert.pem':
381 content => hiera('keystone_signing_certificate'),
384 notify => Service['keystone'],
385 require => File['/etc/keystone/ssl/certs'],
387 file { '/etc/keystone/ssl/private/signing_key.pem':
388 content => hiera('keystone_signing_key'),
391 notify => Service['keystone'],
392 require => File['/etc/keystone/ssl/private'],
394 file { '/etc/keystone/ssl/certs/ca.pem':
395 content => hiera('keystone_ca_certificate'),
398 notify => Service['keystone'],
399 require => File['/etc/keystone/ssl/certs'],
402 $glance_backend = downcase(hiera('glance_backend', 'swift'))
403 case $glance_backend {
404 swift: { $glance_store = 'glance.store.swift.Store' }
405 file: { $glance_store = 'glance.store.filesystem.Store' }
406 rbd: { $glance_store = 'glance.store.rbd.Store' }
407 default: { fail('Unrecognized glance_backend parameter.') }
410 # TODO: notifications, scrubber, etc.
412 class { 'glance::api':
413 known_stores => [$glance_store],
414 manage_service => $non_pcmk_start,
415 enabled => $non_pcmk_start,
417 class { '::glance::registry' :
419 manage_service => $non_pcmk_start,
420 enabled => $non_pcmk_start,
422 include join(['::glance::backend::', $glance_backend])
425 glance_api_servers => join([hiera('glance_protocol'), '://', hiera('controller_virtual_ip'), ':', hiera('glance_port')]),
428 class { '::nova::api' :
430 manage_service => $non_pcmk_start,
431 enabled => $non_pcmk_start,
433 class { '::nova::cert' :
434 manage_service => $non_pcmk_start,
435 enabled => $non_pcmk_start,
437 class { '::nova::conductor' :
438 manage_service => $non_pcmk_start,
439 enabled => $non_pcmk_start,
441 class { '::nova::consoleauth' :
442 manage_service => $non_pcmk_start,
443 enabled => $non_pcmk_start,
445 class { '::nova::vncproxy' :
446 manage_service => $non_pcmk_start,
447 enabled => $non_pcmk_start,
449 class { '::nova::scheduler' :
450 manage_service => $non_pcmk_start,
451 enabled => $non_pcmk_start,
453 include ::nova::network::neutron
456 class { '::neutron::server' :
458 manage_service => $non_pcmk_start,
459 enabled => $non_pcmk_start,
461 class { '::neutron::agents::dhcp' :
462 manage_service => $non_pcmk_start,
463 enabled => $non_pcmk_start,
465 class { '::neutron::agents::l3' :
466 manage_service => $non_pcmk_start,
467 enabled => $non_pcmk_start,
470 file { '/etc/neutron/dnsmasq-neutron.conf':
471 content => hiera('neutron_dnsmasq_options'),
474 notify => Service['neutron-dhcp-service'],
475 require => Package['neutron'],
478 class { 'neutron::plugins::ml2':
479 flat_networks => split(hiera('neutron_flat_networks'), ','),
480 tenant_network_types => [hiera('neutron_tenant_network_type')],
481 type_drivers => [hiera('neutron_tenant_network_type')],
484 class { 'neutron::agents::ml2::ovs':
485 # manage_service => $non_pcmk_start, -- not implemented
486 enabled => $non_pcmk_start,
487 bridge_mappings => split(hiera('neutron_bridge_mappings'), ','),
488 tunnel_types => split(hiera('neutron_tunnel_types'), ','),
491 class { 'neutron::agents::metadata':
492 manage_service => $non_pcmk_start,
493 enabled => $non_pcmk_start,
494 auth_url => join(['http://', hiera('controller_virtual_ip'), ':35357/v2.0']),
497 Service['neutron-server'] -> Service['neutron-dhcp-service']
498 Service['neutron-server'] -> Service['neutron-l3']
499 Service['neutron-server'] -> Service['neutron-ovs-agent-service']
500 Service['neutron-server'] -> Service['neutron-metadata']
503 class { '::cinder::api':
505 manage_service => false,
508 class { '::cinder::scheduler' :
509 manage_service => false,
512 class { '::cinder::volume' :
513 manage_service => false,
516 include ::cinder::glance
517 class {'cinder::setup_test_volume':
518 size => join([hiera('cinder_lvm_loop_device_size'), 'M']),
521 $cinder_enable_iscsi = hiera('cinder_enable_iscsi_backend', true)
522 if $cinder_enable_iscsi {
523 $cinder_iscsi_backend = 'tripleo_iscsi'
525 cinder::backend::iscsi { $cinder_iscsi_backend :
526 iscsi_ip_address => hiera('cinder_iscsi_ip_address'),
527 iscsi_helper => hiera('cinder_iscsi_helper'),
534 pg_num => hiera('ceph::profile::params::osd_pool_default_pg_num'),
535 pgp_num => hiera('ceph::profile::params::osd_pool_default_pgp_num'),
536 size => hiera('ceph::profile::params::osd_pool_default_size'),
539 $ceph_pools = hiera('ceph_pools')
540 ceph::pool { $ceph_pools : }
543 if $cinder_enable_rbd_backend {
544 $cinder_rbd_backend = 'tripleo_ceph'
547 "${cinder_rbd_backend}/host": value => 'hostgroup';
550 cinder::backend::rbd { $cinder_rbd_backend :
551 rbd_pool => 'volumes',
552 rbd_user => 'openstack',
553 rbd_secret_uuid => hiera('ceph::profile::params::fsid'),
554 require => Ceph::Pool['volumes'],
558 $cinder_enabled_backends = delete_undef_values([$cinder_iscsi_backend, $cinder_rbd_backend])
559 class { '::cinder::backends' :
560 enabled_backends => $cinder_enabled_backends,
564 class { '::swift::proxy' :
565 manage_service => $non_pcmk_start,
566 enabled => $non_pcmk_start,
568 include ::swift::proxy::proxy_logging
569 include ::swift::proxy::healthcheck
570 include ::swift::proxy::cache
571 include ::swift::proxy::keystone
572 include ::swift::proxy::authtoken
573 include ::swift::proxy::staticweb
574 include ::swift::proxy::ceilometer
575 include ::swift::proxy::ratelimit
576 include ::swift::proxy::catch_errors
577 include ::swift::proxy::tempurl
578 include ::swift::proxy::formpost
581 if str2bool(hiera('enable_swift_storage', 'true')) {
582 class {'::swift::storage::all':
583 mount_check => str2bool(hiera('swift_mount_check'))
585 class {'::swift::storage::account':
586 manage_service => $non_pcmk_start,
587 enabled => $non_pcmk_start,
589 class {'::swift::storage::container':
590 manage_service => $non_pcmk_start,
591 enabled => $non_pcmk_start,
593 class {'::swift::storage::object':
594 manage_service => $non_pcmk_start,
595 enabled => $non_pcmk_start,
597 if(!defined(File['/srv/node'])) {
602 require => Package['openstack-swift'],
605 $swift_components = ['account', 'container', 'object']
606 swift::storage::filter::recon { $swift_components : }
607 swift::storage::filter::healthcheck { $swift_components : }
611 $ceilometer_backend = downcase(hiera('ceilometer_backend'))
612 case $ceilometer_backend {
614 $ceilometer_database_connection = hiera('ceilometer_mysql_conn_string')
617 $ceilometer_database_connection = "mongodb://${mongo_node_string}/ceilometer?replicaSet=${mongodb_replset}"
621 class { '::ceilometer::api' :
622 manage_service => $non_pcmk_start,
623 enabled => $non_pcmk_start,
625 class { '::ceilometer::agent::notification' :
626 manage_service => $non_pcmk_start,
627 enabled => $non_pcmk_start,
629 class { '::ceilometer::agent::central' :
630 manage_service => $non_pcmk_start,
631 enabled => $non_pcmk_start,
633 class { '::ceilometer::alarm::notifier' :
634 manage_service => $non_pcmk_start,
635 enabled => $non_pcmk_start,
637 class { '::ceilometer::alarm::evaluator' :
638 manage_service => $non_pcmk_start,
639 enabled => $non_pcmk_start,
641 class { '::ceilometer::collector' :
642 manage_service => $non_pcmk_start,
643 enabled => $non_pcmk_start,
645 include ::ceilometer::expirer
646 class { '::ceilometer::db' :
647 database_connection => $ceilometer_database_connection,
650 class { 'ceilometer::agent::auth':
651 auth_url => join(['http://', hiera('controller_virtual_ip'), ':5000/v2.0']),
654 Cron <| title == 'ceilometer-expirer' |> { command => "sleep $((\$(od -A n -t d -N 3 /dev/urandom) % 86400)) && ${::ceilometer::params::expirer_command}" }
660 class { '::heat::api' :
661 manage_service => $non_pcmk_start,
662 enabled => $non_pcmk_start,
664 class { '::heat::api_cfn' :
665 manage_service => $non_pcmk_start,
666 enabled => $non_pcmk_start,
668 class { '::heat::api_cloudwatch' :
669 manage_service => $non_pcmk_start,
670 enabled => $non_pcmk_start,
672 class { '::heat::engine' :
673 manage_service => $non_pcmk_start,
674 enabled => $non_pcmk_start,
678 $vhost_params = { add_listen => false }
680 cache_server_ip => split(hiera('memcache_node_ips', '127.0.0.1'), ','),
681 vhost_extra_params => $vhost_params,
684 $snmpd_user = hiera('snmpd_readonly_user_name')
685 snmp::snmpv3_user { $snmpd_user:
687 authpass => hiera('snmpd_readonly_user_password'),
690 agentaddress => ['udp:161','udp6:[::1]:161'],
691 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' ],
696 if hiera('step') >= 4 {
697 if $pacemaker_master {
700 pacemaker::resource::service { $::cinder::params::api_service :
701 clone_params => "interleave=true",
703 pacemaker::resource::service { $::cinder::params::scheduler_service :
704 clone_params => "interleave=true",
706 pacemaker::resource::service { $::cinder::params::volume_service : }
708 pacemaker::constraint::base { 'cinder-api-then-cinder-scheduler-constraint':
709 constraint_type => "order",
710 first_resource => "${::cinder::params::api_service}-clone",
711 second_resource => "${::cinder::params::scheduler_service}-clone",
712 first_action => "start",
713 second_action => "start",
714 require => [Pacemaker::Resource::Service[$::cinder::params::api_service],
715 Pacemaker::Resource::Service[$::cinder::params::scheduler_service]],
717 pacemaker::constraint::colocation { 'cinder-scheduler-with-cinder-api-colocation':
718 source => "${::cinder::params::scheduler_service}-clone",
719 target => "${::cinder::params::api_service}-clone",
721 require => [Pacemaker::Resource::Service[$::cinder::params::api_service],
722 Pacemaker::Resource::Service[$::cinder::params::scheduler_service]],
724 pacemaker::constraint::base { 'cinder-scheduler-then-cinder-volume-constraint':
725 constraint_type => "order",
726 first_resource => "${::cinder::params::scheduler_service}-clone",
727 second_resource => "${::cinder::params::volume_service}",
728 first_action => "start",
729 second_action => "start",
730 require => [Pacemaker::Resource::Service[$::cinder::params::scheduler_service],
731 Pacemaker::Resource::Service[$::cinder::params::volume_service]],
733 pacemaker::constraint::colocation { 'cinder-volume-with-cinder-scheduler-colocation':
734 source => "${::cinder::params::volume_service}",
735 target => "${::cinder::params::scheduler_service}-clone",
737 require => [Pacemaker::Resource::Service[$::cinder::params::scheduler_service],
738 Pacemaker::Resource::Service[$::cinder::params::volume_service]],