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
16 # TODO(jistr): use pcs resource provider instead of just no-ops
18 tag == 'aodh-service' or
19 tag == 'gnocchi-service'
22 restart => '/bin/true',
27 include ::tripleo::packages
28 include ::tripleo::firewall
30 if $::hostname == downcase(hiera('bootstrap_nodeid')) {
31 $pacemaker_master = true
34 $pacemaker_master = false
38 if hiera('step') >= 1 {
40 if str2bool(hiera('enable_galera', true)) {
41 $mysql_config_file = '/etc/my.cnf.d/galera.cnf'
43 $mysql_config_file = '/etc/my.cnf.d/server.cnf'
45 $galera_nodes = downcase(hiera('galera_node_names', $::hostname))
46 $galera_nodes_count = count(split($galera_nodes, ','))
48 # FIXME: due to https://bugzilla.redhat.com/show_bug.cgi?id=1298671 we
49 # set bind-address to a hostname instead of an ip address; to move Mysql
50 # from internal_api on another network we'll have to customize both
51 # MysqlNetwork and ControllerHostnameResolveNetwork in ServiceNetMap
52 $mysql_bind_host = hiera('mysql_bind_host')
55 'skip-name-resolve' => '1',
56 'binlog_format' => 'ROW',
57 'default-storage-engine' => 'innodb',
58 'innodb_autoinc_lock_mode' => '2',
59 'innodb_locks_unsafe_for_binlog'=> '1',
60 'query_cache_size' => '0',
61 'query_cache_type' => '0',
62 'bind-address' => $::hostname,
63 'max_connections' => hiera('mysql_max_connections'),
64 'open_files_limit' => '-1',
66 'wsrep_provider' => '/usr/lib64/galera/libgalera_smm.so',
67 'wsrep_cluster_name' => 'galera_cluster',
68 'wsrep_cluster_address' => "gcomm://${galera_nodes}",
69 'wsrep_slave_threads' => '1',
70 'wsrep_certify_nonPK' => '1',
71 'wsrep_max_ws_rows' => '131072',
72 'wsrep_max_ws_size' => '1073741824',
74 'wsrep_convert_LOCK_to_trx' => '0',
75 'wsrep_retry_autocommit' => '1',
76 'wsrep_auto_increment_control' => '1',
77 'wsrep_drupal_282555_workaround'=> '0',
78 'wsrep_causal_reads' => '0',
79 'wsrep_sst_method' => 'rsync',
80 'wsrep_provider_options' => "gmcast.listen_addr=tcp://[${mysql_bind_host}]:4567;",
84 class { '::mysql::server':
85 create_root_user => false,
86 create_root_my_cnf => false,
87 config_file => $mysql_config_file,
88 override_options => $mysqld_options,
89 remove_default_accounts => $pacemaker_master,
90 service_manage => false,
91 service_enabled => false,
96 if hiera('step') >= 2 {
99 # NOTE(gfidente): the following vars are needed on all nodes so they
100 # need to stay out of pacemaker_master conditional.
101 # The addresses mangling will hopefully go away when we'll be able to
102 # configure the connection string via hostnames, until then, we need to pass
103 # the list of IPv6 addresses *with* port and without the brackets as 'members'
104 # argument for the 'mongodb_replset' resource.
105 if str2bool(hiera('mongodb::server::ipv6', false)) {
106 $mongo_node_ips_with_port_prefixed = prefix(hiera('mongo_node_ips'), '[')
107 $mongo_node_ips_with_port = suffix($mongo_node_ips_with_port_prefixed, ']:27017')
108 $mongo_node_ips_with_port_nobr = suffix(hiera('mongo_node_ips'), ':27017')
110 $mongo_node_ips_with_port = suffix(hiera('mongo_node_ips'), ':27017')
111 $mongo_node_ips_with_port_nobr = suffix(hiera('mongo_node_ips'), ':27017')
113 $mongodb_replset = hiera('mongodb::server::replset')
115 if $pacemaker_master {
116 pacemaker::resource::ocf { 'galera' :
117 ocf_agent_name => 'heartbeat:galera',
118 op_params => 'promote timeout=300s on-fail=block',
120 meta_params => "master-max=${galera_nodes_count} ordered=true",
121 resource_params => "additional_parameters='--open-files-limit=16384' enable_creation=true wsrep_cluster_address='gcomm://${galera_nodes}'",
122 require => Class['::mysql::server'],
123 before => Exec['galera-ready'],
126 exec { 'galera-ready' :
127 command => '/usr/bin/clustercheck >/dev/null',
131 environment => ['AVAILABLE_WHEN_READONLY=0'],
132 require => Exec['create-root-sysconfig-clustercheck'],
135 # We add a clustercheck db user and we will switch /etc/sysconfig/clustercheck
136 # to it in a later step. We do this only on one node as it will replicate on
137 # the other members. We also make sure that the permissions are the minimum necessary
138 mysql_user { 'clustercheck@localhost':
140 password_hash => mysql_password(hiera('mysql_clustercheck_password')),
141 require => Exec['galera-ready'],
144 mysql_grant { 'clustercheck@localhost/*.*':
146 options => ['GRANT'],
147 privileges => ['PROCESS'],
149 user => 'clustercheck@localhost',
152 class { '::aodh::db::mysql':
153 require => Exec['galera-ready'],
156 # This step is to create a sysconfig clustercheck file with the root user and empty password
157 # on the first install only (because later on the clustercheck db user will be used)
158 # We are using exec and not file in order to not have duplicate definition errors in puppet
159 # when we later set the the file to contain the clustercheck data
160 exec { 'create-root-sysconfig-clustercheck':
161 command => "/bin/echo 'MYSQL_USERNAME=root\nMYSQL_PASSWORD=\'\'\nMYSQL_HOST=localhost\n' > /etc/sysconfig/clustercheck",
162 unless => '/bin/test -e /etc/sysconfig/clustercheck && grep -q clustercheck /etc/sysconfig/clustercheck',
165 xinetd::service { 'galera-monitor' :
167 server => '/usr/bin/clustercheck',
168 per_source => 'UNLIMITED',
169 log_on_success => '',
170 log_on_failure => 'HOST',
172 service_type => 'UNLISTED',
175 require => Exec['create-root-sysconfig-clustercheck'],
180 if hiera('step') >= 4 or ( hiera('step') >= 3 and $sync_db ) {
181 # At this stage we are guaranteed that the clustercheck db user exists
182 # so we switch the resource agent to use it.
183 $mysql_clustercheck_password = hiera('mysql_clustercheck_password')
184 file { '/etc/sysconfig/clustercheck' :
189 content => "MYSQL_USERNAME=clustercheck\n
190 MYSQL_PASSWORD='${mysql_clustercheck_password}'\n
191 MYSQL_HOST=localhost\n",
194 $nova_ipv6 = hiera('nova::use_ipv6', false)
196 $memcached_servers = suffix(hiera('memcache_node_ips_v6'), ':11211')
198 $memcached_servers = suffix(hiera('memcache_node_ips'), ':11211')
202 memcached_servers => $memcached_servers
205 include ::nova::config
209 database_connection => hiera('aodh_mysql_conn_string'),
211 include ::aodh::config
213 include ::aodh::client
214 include ::aodh::wsgi::apache
215 class { '::aodh::api':
216 manage_service => false,
218 service_name => 'httpd',
220 class { '::aodh::evaluator':
221 manage_service => false,
224 class { '::aodh::notifier':
225 manage_service => false,
228 class { '::aodh::listener':
229 manage_service => false,
233 hiera_include('controller_classes')
237 if hiera('step') >= 5 {
238 # We now make sure that the root db password is set to a random one
239 # At first installation /root/.my.cnf will be empty and we connect without a root
240 # password. On second runs or updates /root/.my.cnf will already be populated
241 # with proper credentials. This step happens on every node because this sql
242 # statement does not automatically replicate across nodes.
243 $mysql_root_password = hiera('mysql::server::root_password')
244 exec { 'galera-set-root-password':
245 command => "/bin/touch /root/.my.cnf && /bin/echo \"UPDATE mysql.user SET Password = PASSWORD('${mysql_root_password}') WHERE user = 'root'; flush privileges;\" | /bin/mysql --defaults-extra-file=/root/.my.cnf -u root",
247 file { '/root/.my.cnf' :
254 password=\"${mysql_root_password}\"
258 password=\"${mysql_root_password}\"",
259 require => Exec['galera-set-root-password'],
262 $nova_enable_db_purge = hiera('nova_enable_db_purge', true)
264 if $nova_enable_db_purge {
265 include ::nova::cron::archive_deleted_rows
268 if $pacemaker_master {
270 pacemaker::constraint::base { 'openstack-core-then-httpd-constraint':
271 constraint_type => 'order',
272 first_resource => 'openstack-core-clone',
273 second_resource => "${::apache::params::service_name}-clone",
274 first_action => 'start',
275 second_action => 'start',
276 require => [Pacemaker::Resource::Service[$::apache::params::service_name],
277 Pacemaker::Resource::Ocf['openstack-core']],
279 pacemaker::constraint::base { 'galera-then-openstack-core-constraint':
280 constraint_type => 'order',
281 first_resource => 'galera-master',
282 second_resource => 'openstack-core-clone',
283 first_action => 'promote',
284 second_action => 'start',
285 require => [Pacemaker::Resource::Ocf['galera'],
286 Pacemaker::Resource::Ocf['openstack-core']],
290 pacemaker::constraint::base { 'keystone-then-nova-consoleauth-constraint':
291 constraint_type => 'order',
292 first_resource => 'openstack-core-clone',
293 second_resource => "${::nova::params::consoleauth_service_name}-clone",
294 first_action => 'start',
295 second_action => 'start',
296 require => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
297 Pacemaker::Resource::Ocf['openstack-core']],
299 pacemaker::constraint::colocation { 'nova-consoleauth-with-openstack-core':
300 source => "${::nova::params::consoleauth_service_name}-clone",
301 target => 'openstack-core-clone',
303 require => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
304 Pacemaker::Resource::Ocf['openstack-core']],
306 pacemaker::constraint::base { 'nova-consoleauth-then-nova-vncproxy-constraint':
307 constraint_type => 'order',
308 first_resource => "${::nova::params::consoleauth_service_name}-clone",
309 second_resource => "${::nova::params::vncproxy_service_name}-clone",
310 first_action => 'start',
311 second_action => 'start',
312 require => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
313 Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name]],
315 pacemaker::constraint::colocation { 'nova-vncproxy-with-nova-consoleauth-colocation':
316 source => "${::nova::params::vncproxy_service_name}-clone",
317 target => "${::nova::params::consoleauth_service_name}-clone",
319 require => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
320 Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name]],
322 pacemaker::constraint::base { 'nova-vncproxy-then-nova-api-constraint':
323 constraint_type => 'order',
324 first_resource => "${::nova::params::vncproxy_service_name}-clone",
325 second_resource => "${::nova::params::api_service_name}-clone",
326 first_action => 'start',
327 second_action => 'start',
328 require => [Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name],
329 Pacemaker::Resource::Service[$::nova::params::api_service_name]],
331 pacemaker::constraint::colocation { 'nova-api-with-nova-vncproxy-colocation':
332 source => "${::nova::params::api_service_name}-clone",
333 target => "${::nova::params::vncproxy_service_name}-clone",
335 require => [Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name],
336 Pacemaker::Resource::Service[$::nova::params::api_service_name]],
338 pacemaker::constraint::base { 'nova-api-then-nova-scheduler-constraint':
339 constraint_type => 'order',
340 first_resource => "${::nova::params::api_service_name}-clone",
341 second_resource => "${::nova::params::scheduler_service_name}-clone",
342 first_action => 'start',
343 second_action => 'start',
344 require => [Pacemaker::Resource::Service[$::nova::params::api_service_name],
345 Pacemaker::Resource::Service[$::nova::params::scheduler_service_name]],
347 pacemaker::constraint::colocation { 'nova-scheduler-with-nova-api-colocation':
348 source => "${::nova::params::scheduler_service_name}-clone",
349 target => "${::nova::params::api_service_name}-clone",
351 require => [Pacemaker::Resource::Service[$::nova::params::api_service_name],
352 Pacemaker::Resource::Service[$::nova::params::scheduler_service_name]],
354 pacemaker::constraint::base { 'nova-scheduler-then-nova-conductor-constraint':
355 constraint_type => 'order',
356 first_resource => "${::nova::params::scheduler_service_name}-clone",
357 second_resource => "${::nova::params::conductor_service_name}-clone",
358 first_action => 'start',
359 second_action => 'start',
360 require => [Pacemaker::Resource::Service[$::nova::params::scheduler_service_name],
361 Pacemaker::Resource::Service[$::nova::params::conductor_service_name]],
363 pacemaker::constraint::colocation { 'nova-conductor-with-nova-scheduler-colocation':
364 source => "${::nova::params::conductor_service_name}-clone",
365 target => "${::nova::params::scheduler_service_name}-clone",
367 require => [Pacemaker::Resource::Service[$::nova::params::scheduler_service_name],
368 Pacemaker::Resource::Service[$::nova::params::conductor_service_name]],
371 # Fedora doesn't know `require-all` parameter for constraints yet
372 if $::operatingsystem == 'Fedora' {
373 $redis_aodh_constraint_params = undef
375 $redis_aodh_constraint_params = 'require-all=false'
377 pacemaker::constraint::base { 'redis-then-aodh-evaluator-constraint':
378 constraint_type => 'order',
379 first_resource => 'redis-master',
380 second_resource => "${::aodh::params::evaluator_service_name}-clone",
381 first_action => 'promote',
382 second_action => 'start',
383 constraint_params => $redis_aodh_constraint_params,
384 require => [Pacemaker::Resource::Ocf['redis'],
385 Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name]],
388 pacemaker::resource::service { $::aodh::params::evaluator_service_name :
389 clone_params => 'interleave=true',
391 pacemaker::resource::service { $::aodh::params::notifier_service_name :
392 clone_params => 'interleave=true',
394 pacemaker::resource::service { $::aodh::params::listener_service_name :
395 clone_params => 'interleave=true',
397 pacemaker::constraint::base { 'aodh-evaluator-then-aodh-notifier-constraint':
398 constraint_type => 'order',
399 first_resource => "${::aodh::params::evaluator_service_name}-clone",
400 second_resource => "${::aodh::params::notifier_service_name}-clone",
401 first_action => 'start',
402 second_action => 'start',
403 require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
404 Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
406 pacemaker::constraint::colocation { 'aodh-notifier-with-aodh-evaluator-colocation':
407 source => "${::aodh::params::notifier_service_name}-clone",
408 target => "${::aodh::params::evaluator_service_name}-clone",
410 require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
411 Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
413 pacemaker::constraint::base { 'aodh-evaluator-then-aodh-listener-constraint':
414 constraint_type => 'order',
415 first_resource => "${::aodh::params::evaluator_service_name}-clone",
416 second_resource => "${::aodh::params::listener_service_name}-clone",
417 first_action => 'start',
418 second_action => 'start',
419 require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
420 Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
422 pacemaker::constraint::colocation { 'aodh-listener-with-aodh-evaluator-colocation':
423 source => "${::aodh::params::listener_service_name}-clone",
424 target => "${::aodh::params::evaluator_service_name}-clone",
426 require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
427 Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
430 # Horizon and Keystone
431 pacemaker::resource::service { $::apache::params::service_name:
432 clone_params => 'interleave=true',
433 verify_on_create => true,
434 require => [File['/etc/keystone/ssl/certs/ca.pem'],
435 File['/etc/keystone/ssl/private/signing_key.pem'],
436 File['/etc/keystone/ssl/certs/signing_cert.pem']],
440 if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
441 pacemaker::resource::ocf { 'vsm-p' :
442 ocf_agent_name => 'heartbeat:VirtualDomain',
443 resource_params => 'force_stop=true config=/var/spool/cisco/vsm/vsm_primary_deploy.xml',
444 require => Class['n1k_vsm'],
445 meta_params => 'resource-stickiness=INFINITY',
447 if str2bool(hiera('n1k_vsm::pacemaker_control', true)) {
448 pacemaker::resource::ocf { 'vsm-s' :
449 ocf_agent_name => 'heartbeat:VirtualDomain',
450 resource_params => 'force_stop=true config=/var/spool/cisco/vsm/vsm_secondary_deploy.xml',
451 require => Class['n1k_vsm'],
452 meta_params => 'resource-stickiness=INFINITY',
454 pacemaker::constraint::colocation { 'vsm-colocation-contraint':
457 score => '-INFINITY',
458 require => [Pacemaker::Resource::Ocf['vsm-p'],
459 Pacemaker::Resource::Ocf['vsm-s']],
468 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller_pacemaker', hiera('step')])
469 package_manifest{$package_manifest_name: ensure => present}