835d5689f195f9adc8a1b4c28541a68ca743d565
[apex-tripleo-heat-templates.git] / puppet / manifests / overcloud_controller_pacemaker.pp
1 # Copyright 2015 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 Pcmk_resource <| |> {
17   tries     => 10,
18   try_sleep => 3,
19 }
20
21 # TODO(jistr): use pcs resource provider instead of just no-ops
22 Service <|
23   tag == 'aodh-service' or
24   tag == 'gnocchi-service' or
25   tag == 'neutron-service' or
26   tag == 'nova-service'
27 |> {
28   hasrestart => true,
29   restart    => '/bin/true',
30   start      => '/bin/true',
31   stop       => '/bin/true',
32 }
33
34 include ::tripleo::packages
35 include ::tripleo::firewall
36
37 if $::hostname == downcase(hiera('bootstrap_nodeid')) {
38   $pacemaker_master = true
39   $sync_db = true
40 } else {
41   $pacemaker_master = false
42   $sync_db = false
43 }
44
45 $enable_fencing = str2bool(hiera('enable_fencing', false)) and hiera('step') >= 5
46 $enable_load_balancer = hiera('enable_load_balancer', true)
47
48 # When to start and enable services which haven't been Pacemakerized
49 # FIXME: remove when we start all OpenStack services using Pacemaker
50 # (occurrences of this variable will be gradually replaced with false)
51 $non_pcmk_start = hiera('step') >= 5
52
53 if hiera('step') >= 1 {
54
55   create_resources(kmod::load, hiera('kernel_modules'), {})
56   create_resources(sysctl::value, hiera('sysctl_settings'), {})
57   Exec <| tag == 'kmod::load' |>  -> Sysctl <| |>
58
59   include ::timezone
60
61   $pacemaker_cluster_members = downcase(regsubst(hiera('controller_node_names'), ',', ' ', 'G'))
62   $corosync_ipv6 = str2bool(hiera('corosync_ipv6', false))
63   if $corosync_ipv6 {
64     $cluster_setup_extras = { '--token' => hiera('corosync_token_timeout', 1000), '--ipv6' => '' }
65   } else {
66     $cluster_setup_extras = { '--token' => hiera('corosync_token_timeout', 1000) }
67   }
68   class { '::pacemaker':
69     hacluster_pwd => hiera('hacluster_pwd'),
70   } ->
71   class { '::pacemaker::corosync':
72     cluster_members      => $pacemaker_cluster_members,
73     setup_cluster        => $pacemaker_master,
74     cluster_setup_extras => $cluster_setup_extras,
75   }
76   class { '::pacemaker::stonith':
77     disable => !$enable_fencing,
78   }
79   if $enable_fencing {
80     include ::tripleo::fencing
81
82     # enable stonith after all Pacemaker resources have been created
83     Pcmk_resource<||> -> Class['tripleo::fencing']
84     Pcmk_constraint<||> -> Class['tripleo::fencing']
85     Exec <| tag == 'pacemaker_constraint' |> -> Class['tripleo::fencing']
86     # enable stonith after all fencing devices have been created
87     Class['tripleo::fencing'] -> Class['pacemaker::stonith']
88   }
89
90   # FIXME(gfidente): sets 200secs as default start timeout op
91   # param; until we can use pcmk global defaults we'll still
92   # need to add it to every resource which redefines op params
93   Pacemaker::Resource::Service {
94     op_params => 'start timeout=200s stop timeout=200s',
95   }
96
97   # Galera
98   if str2bool(hiera('enable_galera', true)) {
99     $mysql_config_file = '/etc/my.cnf.d/galera.cnf'
100   } else {
101     $mysql_config_file = '/etc/my.cnf.d/server.cnf'
102   }
103   $galera_nodes = downcase(hiera('galera_node_names', $::hostname))
104   $galera_nodes_count = count(split($galera_nodes, ','))
105
106   # FIXME: due to https://bugzilla.redhat.com/show_bug.cgi?id=1298671 we
107   # set bind-address to a hostname instead of an ip address; to move Mysql
108   # from internal_api on another network we'll have to customize both
109   # MysqlNetwork and ControllerHostnameResolveNetwork in ServiceNetMap
110   $mysql_bind_host = hiera('mysql_bind_host')
111   $mysqld_options = {
112     'mysqld' => {
113       'skip-name-resolve'             => '1',
114       'binlog_format'                 => 'ROW',
115       'default-storage-engine'        => 'innodb',
116       'innodb_autoinc_lock_mode'      => '2',
117       'innodb_locks_unsafe_for_binlog'=> '1',
118       'query_cache_size'              => '0',
119       'query_cache_type'              => '0',
120       'bind-address'                  => $::hostname,
121       'max_connections'               => hiera('mysql_max_connections'),
122       'open_files_limit'              => '-1',
123       'wsrep_on'                      => 'ON',
124       'wsrep_provider'                => '/usr/lib64/galera/libgalera_smm.so',
125       'wsrep_cluster_name'            => 'galera_cluster',
126       'wsrep_cluster_address'         => "gcomm://${galera_nodes}",
127       'wsrep_slave_threads'           => '1',
128       'wsrep_certify_nonPK'           => '1',
129       'wsrep_max_ws_rows'             => '131072',
130       'wsrep_max_ws_size'             => '1073741824',
131       'wsrep_debug'                   => '0',
132       'wsrep_convert_LOCK_to_trx'     => '0',
133       'wsrep_retry_autocommit'        => '1',
134       'wsrep_auto_increment_control'  => '1',
135       'wsrep_drupal_282555_workaround'=> '0',
136       'wsrep_causal_reads'            => '0',
137       'wsrep_sst_method'              => 'rsync',
138       'wsrep_provider_options'        => "gmcast.listen_addr=tcp://[${mysql_bind_host}]:4567;",
139     },
140   }
141
142   class { '::mysql::server':
143     create_root_user        => false,
144     create_root_my_cnf      => false,
145     config_file             => $mysql_config_file,
146     override_options        => $mysqld_options,
147     remove_default_accounts => $pacemaker_master,
148     service_manage          => false,
149     service_enabled         => false,
150   }
151
152 }
153
154 if hiera('step') >= 2 {
155
156
157   # NOTE(gfidente): the following vars are needed on all nodes so they
158   # need to stay out of pacemaker_master conditional.
159   # The addresses mangling will hopefully go away when we'll be able to
160   # configure the connection string via hostnames, until then, we need to pass
161   # the list of IPv6 addresses *with* port and without the brackets as 'members'
162   # argument for the 'mongodb_replset' resource.
163   if str2bool(hiera('mongodb::server::ipv6', false)) {
164     $mongo_node_ips_with_port_prefixed = prefix(hiera('mongo_node_ips'), '[')
165     $mongo_node_ips_with_port = suffix($mongo_node_ips_with_port_prefixed, ']:27017')
166     $mongo_node_ips_with_port_nobr = suffix(hiera('mongo_node_ips'), ':27017')
167   } else {
168     $mongo_node_ips_with_port = suffix(hiera('mongo_node_ips'), ':27017')
169     $mongo_node_ips_with_port_nobr = suffix(hiera('mongo_node_ips'), ':27017')
170   }
171   $mongodb_replset = hiera('mongodb::server::replset')
172
173   if $pacemaker_master {
174
175     include ::pacemaker::resource_defaults
176
177     # Create an openstack-core dummy resource. See RHBZ 1290121
178     pacemaker::resource::ocf { 'openstack-core':
179       ocf_agent_name => 'heartbeat:Dummy',
180       clone_params   => true,
181     }
182
183     pacemaker::resource::ocf { 'galera' :
184       ocf_agent_name  => 'heartbeat:galera',
185       op_params       => 'promote timeout=300s on-fail=block',
186       master_params   => '',
187       meta_params     => "master-max=${galera_nodes_count} ordered=true",
188       resource_params => "additional_parameters='--open-files-limit=16384' enable_creation=true wsrep_cluster_address='gcomm://${galera_nodes}'",
189       require         => Class['::mysql::server'],
190       before          => Exec['galera-ready'],
191     }
192   }
193   $mysql_root_password = hiera('mysql::server::root_password')
194   $mysql_clustercheck_password = hiera('mysql_clustercheck_password')
195   # This step is to create a sysconfig clustercheck file with the root user and empty password
196   # on the first install only (because later on the clustercheck db user will be used)
197   # We are using exec and not file in order to not have duplicate definition errors in puppet
198   # when we later set the the file to contain the clustercheck data
199   exec { 'create-root-sysconfig-clustercheck':
200     command => "/bin/echo 'MYSQL_USERNAME=root\nMYSQL_PASSWORD=\'\'\nMYSQL_HOST=localhost\n' > /etc/sysconfig/clustercheck",
201     unless  => '/bin/test -e /etc/sysconfig/clustercheck && grep -q clustercheck /etc/sysconfig/clustercheck',
202   }
203
204   exec { 'galera-ready' :
205     command     => '/usr/bin/clustercheck >/dev/null',
206     timeout     => 30,
207     tries       => 180,
208     try_sleep   => 10,
209     environment => ['AVAILABLE_WHEN_READONLY=0'],
210     require     => Exec['create-root-sysconfig-clustercheck'],
211   }
212
213   xinetd::service { 'galera-monitor' :
214     port           => '9200',
215     server         => '/usr/bin/clustercheck',
216     per_source     => 'UNLIMITED',
217     log_on_success => '',
218     log_on_failure => 'HOST',
219     flags          => 'REUSE',
220     service_type   => 'UNLISTED',
221     user           => 'root',
222     group          => 'root',
223     require        => Exec['create-root-sysconfig-clustercheck'],
224   }
225   # We add a clustercheck db user and we will switch /etc/sysconfig/clustercheck
226   # to it in a later step. We do this only on one node as it will replicate on
227   # the other members. We also make sure that the permissions are the minimum necessary
228   if $pacemaker_master {
229     mysql_user { 'clustercheck@localhost':
230       ensure        => 'present',
231       password_hash => mysql_password($mysql_clustercheck_password),
232       require       => Exec['galera-ready'],
233     }
234     mysql_grant { 'clustercheck@localhost/*.*':
235       ensure     => 'present',
236       options    => ['GRANT'],
237       privileges => ['PROCESS'],
238       table      => '*.*',
239       user       => 'clustercheck@localhost',
240     }
241   }
242
243   # Create all the database schemas
244   if $sync_db {
245     if downcase(hiera('gnocchi_indexer_backend')) == 'mysql' {
246       class { '::gnocchi::db::mysql':
247         require => Exec['galera-ready'],
248       }
249     }
250
251     class { '::aodh::db::mysql':
252         require => Exec['galera-ready'],
253       }
254   }
255
256   # Ceph
257   $enable_ceph = hiera('ceph_storage_count', 0) > 0 or hiera('enable_ceph_storage', false)
258
259   if $enable_ceph {
260     $mon_initial_members = downcase(hiera('ceph_mon_initial_members'))
261     if str2bool(hiera('ceph_ipv6', false)) {
262       $mon_host = hiera('ceph_mon_host_v6')
263     } else {
264       $mon_host = hiera('ceph_mon_host')
265     }
266     class { '::ceph::profile::params':
267       mon_initial_members => $mon_initial_members,
268       mon_host            => $mon_host,
269     }
270     include ::ceph::conf
271     include ::ceph::profile::mon
272   }
273
274   if str2bool(hiera('enable_ceph_storage', false)) {
275     if str2bool(hiera('ceph_osd_selinux_permissive', true)) {
276       exec { 'set selinux to permissive on boot':
277         command => "sed -ie 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config",
278         onlyif  => "test -f /etc/selinux/config && ! grep '^SELINUX=permissive' /etc/selinux/config",
279         path    => ['/usr/bin', '/usr/sbin'],
280       }
281
282       exec { 'set selinux to permissive':
283         command => 'setenforce 0',
284         onlyif  => "which setenforce && getenforce | grep -i 'enforcing'",
285         path    => ['/usr/bin', '/usr/sbin'],
286       } -> Class['ceph::profile::osd']
287     }
288
289     include ::ceph::conf
290     include ::ceph::profile::osd
291   }
292
293   if str2bool(hiera('enable_external_ceph', false)) {
294     if str2bool(hiera('ceph_ipv6', false)) {
295       $mon_host = hiera('ceph_mon_host_v6')
296     } else {
297       $mon_host = hiera('ceph_mon_host')
298     }
299     class { '::ceph::profile::params':
300       mon_host            => $mon_host,
301     }
302     include ::ceph::conf
303     include ::ceph::profile::client
304   }
305
306
307 } #END STEP 2
308
309 if hiera('step') >= 4 or ( hiera('step') >= 3 and $sync_db ) {
310   # At this stage we are guaranteed that the clustercheck db user exists
311   # so we switch the resource agent to use it.
312   file { '/etc/sysconfig/clustercheck' :
313     ensure  => file,
314     mode    => '0600',
315     owner   => 'root',
316     group   => 'root',
317     content => "MYSQL_USERNAME=clustercheck\n
318 MYSQL_PASSWORD='${mysql_clustercheck_password}'\n
319 MYSQL_HOST=localhost\n",
320   }
321
322   $nova_ipv6 = hiera('nova::use_ipv6', false)
323   if $nova_ipv6 {
324     $memcached_servers = suffix(hiera('memcache_node_ips_v6'), ':11211')
325   } else {
326     $memcached_servers = suffix(hiera('memcache_node_ips'), ':11211')
327   }
328
329   class { '::nova' :
330     memcached_servers => $memcached_servers
331   }
332
333   include ::nova::config
334
335   if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
336
337     # TODO(devvesa) provide non-controller ips for these services
338     $zookeeper_node_ips = hiera('neutron_api_node_ips')
339     $cassandra_node_ips = hiera('neutron_api_node_ips')
340
341     # Run zookeeper in the controller if configured
342     if hiera('enable_zookeeper_on_controller') {
343       class {'::tripleo::cluster::zookeeper':
344         zookeeper_server_ips => $zookeeper_node_ips,
345         # TODO: create a 'bind' hiera key for zookeeper
346         zookeeper_client_ip  => hiera('neutron::bind_host'),
347         zookeeper_hostnames  => split(hiera('controller_node_names'), ',')
348       }
349     }
350
351     # Run cassandra in the controller if configured
352     if hiera('enable_cassandra_on_controller') {
353       class {'::tripleo::cluster::cassandra':
354         cassandra_servers => $cassandra_node_ips,
355         # TODO: create a 'bind' hiera key for cassandra
356         cassandra_ip      => hiera('neutron::bind_host'),
357       }
358     }
359
360     class {'::tripleo::network::midonet::agent':
361       zookeeper_servers => $zookeeper_node_ips,
362       cassandra_seeds   => $cassandra_node_ips
363     }
364
365     class {'::tripleo::network::midonet::api':
366       zookeeper_servers    => $zookeeper_node_ips,
367       vip                  => hiera('public_virtual_ip'),
368       keystone_ip          => hiera('public_virtual_ip'),
369       keystone_admin_token => hiera('keystone::admin_token'),
370       # TODO: create a 'bind' hiera key for api
371       bind_address         => hiera('neutron::bind_host'),
372       admin_password       => hiera('admin_password')
373     }
374
375     # Configure Neutron
376     # TODO: when doing the composable midonet plugin, don't forget to
377     # set service_plugins to an empty array in Hiera.
378     class {'::neutron':
379       service_plugins => []
380     }
381
382   }
383
384   if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
385     class {'::neutron::plugins::midonet':
386       midonet_api_ip    => hiera('public_virtual_ip'),
387       keystone_tenant   => hiera('neutron::server::auth_tenant'),
388       keystone_password => hiera('neutron::server::password')
389     }
390   }
391
392   if $enable_ceph {
393     $ceph_pools = hiera('ceph_pools')
394     ceph::pool { $ceph_pools :
395       pg_num  => hiera('ceph::profile::params::osd_pool_default_pg_num'),
396       pgp_num => hiera('ceph::profile::params::osd_pool_default_pgp_num'),
397       size    => hiera('ceph::profile::params::osd_pool_default_size'),
398     }
399   }
400
401   # swift storage
402   if str2bool(hiera('enable_swift_storage', true)) {
403     class {'::swift::storage::all':
404       mount_check => str2bool(hiera('swift_mount_check')),
405     }
406     class {'::swift::storage::account':
407       manage_service => $non_pcmk_start,
408       enabled        => $non_pcmk_start,
409     }
410     class {'::swift::storage::container':
411       manage_service => $non_pcmk_start,
412       enabled        => $non_pcmk_start,
413     }
414     class {'::swift::storage::object':
415       manage_service => $non_pcmk_start,
416       enabled        => $non_pcmk_start,
417     }
418     if(!defined(File['/srv/node'])) {
419       file { '/srv/node':
420         ensure  => directory,
421         owner   => 'swift',
422         group   => 'swift',
423         require => Package['openstack-swift'],
424       }
425     }
426     $swift_components = ['account', 'container', 'object']
427     swift::storage::filter::recon { $swift_components : }
428     swift::storage::filter::healthcheck { $swift_components : }
429   }
430
431   # httpd/apache and horizon
432   # NOTE(gfidente): server-status can be consumed by the pacemaker resource agent
433   class { '::apache' :
434     service_enable => false,
435     # service_manage => false, # <-- not supported with horizon&apache mod_wsgi?
436   }
437   include ::apache::mod::remoteip
438   include ::apache::mod::status
439   if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
440     $_profile_support = 'cisco'
441   } else {
442     $_profile_support = 'None'
443   }
444   $neutron_options   = {'profile_support' => $_profile_support }
445
446   $memcached_ipv6 = hiera('memcached_ipv6', false)
447   if $memcached_ipv6 {
448     $horizon_memcached_servers = hiera('memcache_node_ips_v6', '[::1]')
449   } else {
450     $horizon_memcached_servers = hiera('memcache_node_ips', '127.0.0.1')
451   }
452
453   class { '::horizon':
454     cache_server_ip => $horizon_memcached_servers,
455     neutron_options => $neutron_options,
456   }
457
458   # Aodh
459   class { '::aodh' :
460     database_connection => hiera('aodh_mysql_conn_string'),
461   }
462   include ::aodh::config
463   include ::aodh::auth
464   include ::aodh::client
465   include ::aodh::wsgi::apache
466   class { '::aodh::api':
467     manage_service => false,
468     enabled        => false,
469     service_name   => 'httpd',
470   }
471   class { '::aodh::evaluator':
472     manage_service => false,
473     enabled        => false,
474   }
475   class { '::aodh::notifier':
476     manage_service => false,
477     enabled        => false,
478   }
479   class { '::aodh::listener':
480     manage_service => false,
481     enabled        => false,
482   }
483
484   # Gnocchi
485   $gnocchi_database_connection = hiera('gnocchi_mysql_conn_string')
486   include ::gnocchi::client
487   if $sync_db {
488     include ::gnocchi::db::sync
489   }
490   include ::gnocchi::storage
491   $gnocchi_backend = downcase(hiera('gnocchi_backend', 'swift'))
492   case $gnocchi_backend {
493       'swift': { include ::gnocchi::storage::swift }
494       'file': { include ::gnocchi::storage::file }
495       'rbd': { include ::gnocchi::storage::ceph }
496       default: { fail('Unrecognized gnocchi_backend parameter.') }
497   }
498   class { '::gnocchi':
499     database_connection => $gnocchi_database_connection,
500   }
501   class { '::gnocchi::api' :
502     manage_service => false,
503     enabled        => false,
504     service_name   => 'httpd',
505   }
506   class { '::gnocchi::wsgi::apache' :
507     ssl => false,
508   }
509   class { '::gnocchi::metricd' :
510     manage_service => false,
511     enabled        => false,
512   }
513   class { '::gnocchi::statsd' :
514     manage_service => false,
515     enabled        => false,
516   }
517
518   $snmpd_user = hiera('snmpd_readonly_user_name')
519   snmp::snmpv3_user { $snmpd_user:
520     authtype => 'MD5',
521     authpass => hiera('snmpd_readonly_user_password'),
522   }
523   class { '::snmp':
524     agentaddress => ['udp:161','udp6:[::1]:161'],
525     snmpd_config => [ join(['createUser ', hiera('snmpd_readonly_user_name'), ' MD5 "', hiera('snmpd_readonly_user_password'), '"']), join(['rouser ', hiera('snmpd_readonly_user_name')]), 'proc  cron', 'includeAllDisks  10%', 'master agentx', 'trapsink localhost public', 'iquerySecName internalUser', 'rouser internalUser', 'defaultMonitors yes', 'linkUpDownNotifications yes' ],
526   }
527
528   hiera_include('controller_classes')
529
530 } #END STEP 4
531
532 if hiera('step') >= 5 {
533   # We now make sure that the root db password is set to a random one
534   # At first installation /root/.my.cnf will be empty and we connect without a root
535   # password. On second runs or updates /root/.my.cnf will already be populated
536   # with proper credentials. This step happens on every node because this sql
537   # statement does not automatically replicate across nodes.
538   exec { 'galera-set-root-password':
539     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",
540   }
541   file { '/root/.my.cnf' :
542     ensure  => file,
543     mode    => '0600',
544     owner   => 'root',
545     group   => 'root',
546     content => "[client]
547 user=root
548 password=\"${mysql_root_password}\"
549
550 [mysql]
551 user=root
552 password=\"${mysql_root_password}\"",
553     require => Exec['galera-set-root-password'],
554   }
555
556   $nova_enable_db_purge = hiera('nova_enable_db_purge', true)
557
558   if $nova_enable_db_purge {
559     include ::nova::cron::archive_deleted_rows
560   }
561
562   if $pacemaker_master {
563
564     pacemaker::constraint::base { 'openstack-core-then-httpd-constraint':
565       constraint_type => 'order',
566       first_resource  => 'openstack-core-clone',
567       second_resource => "${::apache::params::service_name}-clone",
568       first_action    => 'start',
569       second_action   => 'start',
570       require         => [Pacemaker::Resource::Service[$::apache::params::service_name],
571                           Pacemaker::Resource::Ocf['openstack-core']],
572     }
573     pacemaker::constraint::base { 'galera-then-openstack-core-constraint':
574       constraint_type => 'order',
575       first_resource  => 'galera-master',
576       second_resource => 'openstack-core-clone',
577       first_action    => 'promote',
578       second_action   => 'start',
579       require         => [Pacemaker::Resource::Ocf['galera'],
580                           Pacemaker::Resource::Ocf['openstack-core']],
581     }
582
583     if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
584       pacemaker::resource::service {'tomcat':
585         clone_params => 'interleave=true',
586       }
587     }
588     if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
589       #midonet-chain chain keystone-->neutron-server-->dhcp-->metadata->tomcat
590       pacemaker::constraint::base { 'neutron-server-to-dhcp-agent-constraint':
591         constraint_type => 'order',
592         first_resource  => "${::neutron::params::server_service}-clone",
593         second_resource => "${::neutron::params::dhcp_agent_service}-clone",
594         first_action    => 'start',
595         second_action   => 'start',
596         require         => [Pacemaker::Resource::Service[$::neutron::params::server_service],
597                             Pacemaker::Resource::Service[$::neutron::params::dhcp_agent_service]],
598       }
599       pacemaker::constraint::base { 'neutron-dhcp-agent-to-metadata-agent-constraint':
600         constraint_type => 'order',
601         first_resource  => "${::neutron::params::dhcp_agent_service}-clone",
602         second_resource => "${::neutron::params::metadata_agent_service}-clone",
603         first_action    => 'start',
604         second_action   => 'start',
605         require         => [Pacemaker::Resource::Service[$::neutron::params::dhcp_agent_service],
606                             Pacemaker::Resource::Service[$::neutron::params::metadata_agent_service]],
607       }
608       pacemaker::constraint::base { 'neutron-metadata-agent-to-tomcat-constraint':
609         constraint_type => 'order',
610         first_resource  => "${::neutron::params::metadata_agent_service}-clone",
611         second_resource => 'tomcat-clone',
612         first_action    => 'start',
613         second_action   => 'start',
614         require         => [Pacemaker::Resource::Service[$::neutron::params::metadata_agent_service],
615                             Pacemaker::Resource::Service['tomcat']],
616       }
617       pacemaker::constraint::colocation { 'neutron-dhcp-agent-to-metadata-agent-colocation':
618         source  => "${::neutron::params::metadata_agent_service}-clone",
619         target  => "${::neutron::params::dhcp_agent_service}-clone",
620         score   => 'INFINITY',
621         require => [Pacemaker::Resource::Service[$::neutron::params::dhcp_agent_service],
622                     Pacemaker::Resource::Service[$::neutron::params::metadata_agent_service]],
623       }
624     }
625
626     # Nova
627     pacemaker::constraint::base { 'keystone-then-nova-consoleauth-constraint':
628       constraint_type => 'order',
629       first_resource  => 'openstack-core-clone',
630       second_resource => "${::nova::params::consoleauth_service_name}-clone",
631       first_action    => 'start',
632       second_action   => 'start',
633       require         => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
634                           Pacemaker::Resource::Ocf['openstack-core']],
635     }
636     pacemaker::constraint::colocation { 'nova-consoleauth-with-openstack-core':
637       source  => "${::nova::params::consoleauth_service_name}-clone",
638       target  => 'openstack-core-clone',
639       score   => 'INFINITY',
640       require => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
641                   Pacemaker::Resource::Ocf['openstack-core']],
642     }
643     pacemaker::constraint::base { 'nova-consoleauth-then-nova-vncproxy-constraint':
644       constraint_type => 'order',
645       first_resource  => "${::nova::params::consoleauth_service_name}-clone",
646       second_resource => "${::nova::params::vncproxy_service_name}-clone",
647       first_action    => 'start',
648       second_action   => 'start',
649       require         => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
650                           Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name]],
651     }
652     pacemaker::constraint::colocation { 'nova-vncproxy-with-nova-consoleauth-colocation':
653       source  => "${::nova::params::vncproxy_service_name}-clone",
654       target  => "${::nova::params::consoleauth_service_name}-clone",
655       score   => 'INFINITY',
656       require => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
657                   Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name]],
658     }
659     pacemaker::constraint::base { 'nova-vncproxy-then-nova-api-constraint':
660       constraint_type => 'order',
661       first_resource  => "${::nova::params::vncproxy_service_name}-clone",
662       second_resource => "${::nova::params::api_service_name}-clone",
663       first_action    => 'start',
664       second_action   => 'start',
665       require         => [Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name],
666                           Pacemaker::Resource::Service[$::nova::params::api_service_name]],
667     }
668     pacemaker::constraint::colocation { 'nova-api-with-nova-vncproxy-colocation':
669       source  => "${::nova::params::api_service_name}-clone",
670       target  => "${::nova::params::vncproxy_service_name}-clone",
671       score   => 'INFINITY',
672       require => [Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name],
673                   Pacemaker::Resource::Service[$::nova::params::api_service_name]],
674     }
675     pacemaker::constraint::base { 'nova-api-then-nova-scheduler-constraint':
676       constraint_type => 'order',
677       first_resource  => "${::nova::params::api_service_name}-clone",
678       second_resource => "${::nova::params::scheduler_service_name}-clone",
679       first_action    => 'start',
680       second_action   => 'start',
681       require         => [Pacemaker::Resource::Service[$::nova::params::api_service_name],
682                           Pacemaker::Resource::Service[$::nova::params::scheduler_service_name]],
683     }
684     pacemaker::constraint::colocation { 'nova-scheduler-with-nova-api-colocation':
685       source  => "${::nova::params::scheduler_service_name}-clone",
686       target  => "${::nova::params::api_service_name}-clone",
687       score   => 'INFINITY',
688       require => [Pacemaker::Resource::Service[$::nova::params::api_service_name],
689                   Pacemaker::Resource::Service[$::nova::params::scheduler_service_name]],
690     }
691     pacemaker::constraint::base { 'nova-scheduler-then-nova-conductor-constraint':
692       constraint_type => 'order',
693       first_resource  => "${::nova::params::scheduler_service_name}-clone",
694       second_resource => "${::nova::params::conductor_service_name}-clone",
695       first_action    => 'start',
696       second_action   => 'start',
697       require         => [Pacemaker::Resource::Service[$::nova::params::scheduler_service_name],
698                           Pacemaker::Resource::Service[$::nova::params::conductor_service_name]],
699     }
700     pacemaker::constraint::colocation { 'nova-conductor-with-nova-scheduler-colocation':
701       source  => "${::nova::params::conductor_service_name}-clone",
702       target  => "${::nova::params::scheduler_service_name}-clone",
703       score   => 'INFINITY',
704       require => [Pacemaker::Resource::Service[$::nova::params::scheduler_service_name],
705                   Pacemaker::Resource::Service[$::nova::params::conductor_service_name]],
706     }
707
708     # Fedora doesn't know `require-all` parameter for constraints yet
709     if $::operatingsystem == 'Fedora' {
710       $redis_aodh_constraint_params = undef
711     } else {
712       $redis_aodh_constraint_params = 'require-all=false'
713     }
714     pacemaker::constraint::base { 'redis-then-aodh-evaluator-constraint':
715       constraint_type   => 'order',
716       first_resource    => 'redis-master',
717       second_resource   => "${::aodh::params::evaluator_service_name}-clone",
718       first_action      => 'promote',
719       second_action     => 'start',
720       constraint_params => $redis_aodh_constraint_params,
721       require           => [Pacemaker::Resource::Ocf['redis'],
722                             Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name]],
723     }
724     # Aodh
725     pacemaker::resource::service { $::aodh::params::evaluator_service_name :
726       clone_params => 'interleave=true',
727     }
728     pacemaker::resource::service { $::aodh::params::notifier_service_name :
729       clone_params => 'interleave=true',
730     }
731     pacemaker::resource::service { $::aodh::params::listener_service_name :
732       clone_params => 'interleave=true',
733     }
734     pacemaker::constraint::base { 'aodh-evaluator-then-aodh-notifier-constraint':
735       constraint_type => 'order',
736       first_resource  => "${::aodh::params::evaluator_service_name}-clone",
737       second_resource => "${::aodh::params::notifier_service_name}-clone",
738       first_action    => 'start',
739       second_action   => 'start',
740       require         => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
741                           Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
742     }
743     pacemaker::constraint::colocation { 'aodh-notifier-with-aodh-evaluator-colocation':
744       source  => "${::aodh::params::notifier_service_name}-clone",
745       target  => "${::aodh::params::evaluator_service_name}-clone",
746       score   => 'INFINITY',
747       require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
748                   Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
749     }
750     pacemaker::constraint::base { 'aodh-evaluator-then-aodh-listener-constraint':
751       constraint_type => 'order',
752       first_resource  => "${::aodh::params::evaluator_service_name}-clone",
753       second_resource => "${::aodh::params::listener_service_name}-clone",
754       first_action    => 'start',
755       second_action   => 'start',
756       require         => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
757                           Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
758     }
759     pacemaker::constraint::colocation { 'aodh-listener-with-aodh-evaluator-colocation':
760       source  => "${::aodh::params::listener_service_name}-clone",
761       target  => "${::aodh::params::evaluator_service_name}-clone",
762       score   => 'INFINITY',
763       require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
764                   Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
765     }
766
767     # gnocchi
768     pacemaker::resource::service { $::gnocchi::params::metricd_service_name :
769       clone_params => 'interleave=true',
770     }
771     pacemaker::resource::service { $::gnocchi::params::statsd_service_name :
772       clone_params => 'interleave=true',
773     }
774     pacemaker::constraint::base { 'gnocchi-metricd-then-gnocchi-statsd-constraint':
775       constraint_type => 'order',
776       first_resource  => "${::gnocchi::params::metricd_service_name}-clone",
777       second_resource => "${::gnocchi::params::statsd_service_name}-clone",
778       first_action    => 'start',
779       second_action   => 'start',
780       require         => [Pacemaker::Resource::Service[$::gnocchi::params::metricd_service_name],
781                           Pacemaker::Resource::Service[$::gnocchi::params::statsd_service_name]],
782     }
783     pacemaker::constraint::colocation { 'gnocchi-statsd-with-metricd-colocation':
784       source  => "${::gnocchi::params::statsd_service_name}-clone",
785       target  => "${::gnocchi::params::metricd_service_name}-clone",
786       score   => 'INFINITY',
787       require => [Pacemaker::Resource::Service[$::gnocchi::params::metricd_service_name],
788                   Pacemaker::Resource::Service[$::gnocchi::params::statsd_service_name]],
789     }
790
791     # Horizon and Keystone
792     pacemaker::resource::service { $::apache::params::service_name:
793       clone_params     => 'interleave=true',
794       verify_on_create => true,
795       require          => [File['/etc/keystone/ssl/certs/ca.pem'],
796       File['/etc/keystone/ssl/private/signing_key.pem'],
797       File['/etc/keystone/ssl/certs/signing_cert.pem']],
798     }
799
800     #VSM
801     if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
802       pacemaker::resource::ocf { 'vsm-p' :
803         ocf_agent_name  => 'heartbeat:VirtualDomain',
804         resource_params => 'force_stop=true config=/var/spool/cisco/vsm/vsm_primary_deploy.xml',
805         require         => Class['n1k_vsm'],
806         meta_params     => 'resource-stickiness=INFINITY',
807       }
808       if str2bool(hiera('n1k_vsm::pacemaker_control', true)) {
809         pacemaker::resource::ocf { 'vsm-s' :
810           ocf_agent_name  => 'heartbeat:VirtualDomain',
811           resource_params => 'force_stop=true config=/var/spool/cisco/vsm/vsm_secondary_deploy.xml',
812           require         => Class['n1k_vsm'],
813           meta_params     => 'resource-stickiness=INFINITY',
814         }
815         pacemaker::constraint::colocation { 'vsm-colocation-contraint':
816           source  => 'vsm-p',
817           target  => 'vsm-s',
818           score   => '-INFINITY',
819           require => [Pacemaker::Resource::Ocf['vsm-p'],
820                       Pacemaker::Resource::Ocf['vsm-s']],
821         }
822       }
823     }
824
825   }
826
827 } #END STEP 5
828
829 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller_pacemaker', hiera('step')])
830 package_manifest{$package_manifest_name: ensure => present}