Merge "move hieradata/ceph into ceph-base service"
[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 # TODO(jistr): use pcs resource provider instead of just no-ops
17 Service <|
18   tag == 'aodh-service'
19 |> {
20   hasrestart => true,
21   restart    => '/bin/true',
22   start      => '/bin/true',
23   stop       => '/bin/true',
24 }
25
26 include ::tripleo::packages
27 include ::tripleo::firewall
28
29 if $::hostname == downcase(hiera('bootstrap_nodeid')) {
30   $pacemaker_master = true
31   $sync_db = true
32 } else {
33   $pacemaker_master = false
34   $sync_db = false
35 }
36
37 if hiera('step') >= 2 {
38   if $pacemaker_master {
39     class { '::aodh::db::mysql':
40         require => Exec['galera-ready'],
41     }
42   }
43 } #END STEP 2
44
45 if hiera('step') >= 4 or ( hiera('step') >= 3 and $sync_db ) {
46   # Aodh
47   class { '::aodh' :
48     database_connection => hiera('aodh_mysql_conn_string'),
49   }
50   include ::aodh::config
51   include ::aodh::auth
52   include ::aodh::client
53   include ::aodh::wsgi::apache
54   class { '::aodh::api':
55     manage_service => false,
56     enabled        => false,
57     service_name   => 'httpd',
58   }
59   class { '::aodh::evaluator':
60     manage_service => false,
61     enabled        => false,
62   }
63   class { '::aodh::notifier':
64     manage_service => false,
65     enabled        => false,
66   }
67   class { '::aodh::listener':
68     manage_service => false,
69     enabled        => false,
70   }
71
72   hiera_include('controller_classes')
73
74 } #END STEP 4
75
76 if hiera('step') >= 5 {
77   if $pacemaker_master {
78
79     # Fedora doesn't know `require-all` parameter for constraints yet
80     if $::operatingsystem == 'Fedora' {
81       $redis_aodh_constraint_params = undef
82     } else {
83       $redis_aodh_constraint_params = 'require-all=false'
84     }
85     pacemaker::constraint::base { 'redis-then-aodh-evaluator-constraint':
86       constraint_type   => 'order',
87       first_resource    => 'redis-master',
88       second_resource   => "${::aodh::params::evaluator_service_name}-clone",
89       first_action      => 'promote',
90       second_action     => 'start',
91       constraint_params => $redis_aodh_constraint_params,
92       require           => [Pacemaker::Resource::Ocf['redis'],
93                             Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name]],
94     }
95     # Aodh
96     pacemaker::resource::service { $::aodh::params::evaluator_service_name :
97       clone_params => 'interleave=true',
98     }
99     pacemaker::resource::service { $::aodh::params::notifier_service_name :
100       clone_params => 'interleave=true',
101     }
102     pacemaker::resource::service { $::aodh::params::listener_service_name :
103       clone_params => 'interleave=true',
104     }
105     pacemaker::constraint::base { 'aodh-evaluator-then-aodh-notifier-constraint':
106       constraint_type => 'order',
107       first_resource  => "${::aodh::params::evaluator_service_name}-clone",
108       second_resource => "${::aodh::params::notifier_service_name}-clone",
109       first_action    => 'start',
110       second_action   => 'start',
111       require         => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
112                           Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
113     }
114     pacemaker::constraint::colocation { 'aodh-notifier-with-aodh-evaluator-colocation':
115       source  => "${::aodh::params::notifier_service_name}-clone",
116       target  => "${::aodh::params::evaluator_service_name}-clone",
117       score   => 'INFINITY',
118       require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
119                   Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
120     }
121     pacemaker::constraint::base { 'aodh-evaluator-then-aodh-listener-constraint':
122       constraint_type => 'order',
123       first_resource  => "${::aodh::params::evaluator_service_name}-clone",
124       second_resource => "${::aodh::params::listener_service_name}-clone",
125       first_action    => 'start',
126       second_action   => 'start',
127       require         => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
128                           Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
129     }
130     pacemaker::constraint::colocation { 'aodh-listener-with-aodh-evaluator-colocation':
131       source  => "${::aodh::params::listener_service_name}-clone",
132       target  => "${::aodh::params::evaluator_service_name}-clone",
133       score   => 'INFINITY',
134       require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
135                   Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
136     }
137   }
138
139 } #END STEP 5
140
141 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller_pacemaker', hiera('step')])
142 package_manifest{$package_manifest_name: ensure => present}