Merge "Remove useless mongodb variables in ha manifest"
[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' or
19   tag == 'gnocchi-service'
20 |> {
21   hasrestart => true,
22   restart    => '/bin/true',
23   start      => '/bin/true',
24   stop       => '/bin/true',
25 }
26
27 include ::tripleo::packages
28 include ::tripleo::firewall
29
30 if $::hostname == downcase(hiera('bootstrap_nodeid')) {
31   $pacemaker_master = true
32   $sync_db = true
33 } else {
34   $pacemaker_master = false
35   $sync_db = false
36 }
37
38 if hiera('step') >= 2 {
39   if $pacemaker_master {
40     class { '::aodh::db::mysql':
41         require => Exec['galera-ready'],
42     }
43   }
44 } #END STEP 2
45
46 if hiera('step') >= 4 or ( hiera('step') >= 3 and $sync_db ) {
47   $nova_ipv6 = hiera('nova::use_ipv6', false)
48   if $nova_ipv6 {
49     $memcached_servers = suffix(hiera('memcache_node_ips_v6'), ':11211')
50   } else {
51     $memcached_servers = suffix(hiera('memcache_node_ips'), ':11211')
52   }
53
54   class { '::nova' :
55     memcached_servers => $memcached_servers
56   }
57
58   include ::nova::config
59
60   # Aodh
61   class { '::aodh' :
62     database_connection => hiera('aodh_mysql_conn_string'),
63   }
64   include ::aodh::config
65   include ::aodh::auth
66   include ::aodh::client
67   include ::aodh::wsgi::apache
68   class { '::aodh::api':
69     manage_service => false,
70     enabled        => false,
71     service_name   => 'httpd',
72   }
73   class { '::aodh::evaluator':
74     manage_service => false,
75     enabled        => false,
76   }
77   class { '::aodh::notifier':
78     manage_service => false,
79     enabled        => false,
80   }
81   class { '::aodh::listener':
82     manage_service => false,
83     enabled        => false,
84   }
85
86   hiera_include('controller_classes')
87
88 } #END STEP 4
89
90 if hiera('step') >= 5 {
91   $nova_enable_db_purge = hiera('nova_enable_db_purge', true)
92   if $nova_enable_db_purge {
93     include ::nova::cron::archive_deleted_rows
94   }
95
96   if $pacemaker_master {
97
98     pacemaker::constraint::base { 'openstack-core-then-httpd-constraint':
99       constraint_type => 'order',
100       first_resource  => 'openstack-core-clone',
101       second_resource => "${::apache::params::service_name}-clone",
102       first_action    => 'start',
103       second_action   => 'start',
104       require         => [Pacemaker::Resource::Service[$::apache::params::service_name],
105                           Pacemaker::Resource::Ocf['openstack-core']],
106     }
107
108     # Nova
109     pacemaker::constraint::base { 'keystone-then-nova-consoleauth-constraint':
110       constraint_type => 'order',
111       first_resource  => 'openstack-core-clone',
112       second_resource => "${::nova::params::consoleauth_service_name}-clone",
113       first_action    => 'start',
114       second_action   => 'start',
115       require         => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
116                           Pacemaker::Resource::Ocf['openstack-core']],
117     }
118     pacemaker::constraint::colocation { 'nova-consoleauth-with-openstack-core':
119       source  => "${::nova::params::consoleauth_service_name}-clone",
120       target  => 'openstack-core-clone',
121       score   => 'INFINITY',
122       require => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
123                   Pacemaker::Resource::Ocf['openstack-core']],
124     }
125     pacemaker::constraint::base { 'nova-consoleauth-then-nova-vncproxy-constraint':
126       constraint_type => 'order',
127       first_resource  => "${::nova::params::consoleauth_service_name}-clone",
128       second_resource => "${::nova::params::vncproxy_service_name}-clone",
129       first_action    => 'start',
130       second_action   => 'start',
131       require         => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
132                           Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name]],
133     }
134     pacemaker::constraint::colocation { 'nova-vncproxy-with-nova-consoleauth-colocation':
135       source  => "${::nova::params::vncproxy_service_name}-clone",
136       target  => "${::nova::params::consoleauth_service_name}-clone",
137       score   => 'INFINITY',
138       require => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
139                   Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name]],
140     }
141     pacemaker::constraint::base { 'nova-vncproxy-then-nova-api-constraint':
142       constraint_type => 'order',
143       first_resource  => "${::nova::params::vncproxy_service_name}-clone",
144       second_resource => "${::nova::params::api_service_name}-clone",
145       first_action    => 'start',
146       second_action   => 'start',
147       require         => [Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name],
148                           Pacemaker::Resource::Service[$::nova::params::api_service_name]],
149     }
150     pacemaker::constraint::colocation { 'nova-api-with-nova-vncproxy-colocation':
151       source  => "${::nova::params::api_service_name}-clone",
152       target  => "${::nova::params::vncproxy_service_name}-clone",
153       score   => 'INFINITY',
154       require => [Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name],
155                   Pacemaker::Resource::Service[$::nova::params::api_service_name]],
156     }
157     pacemaker::constraint::base { 'nova-api-then-nova-scheduler-constraint':
158       constraint_type => 'order',
159       first_resource  => "${::nova::params::api_service_name}-clone",
160       second_resource => "${::nova::params::scheduler_service_name}-clone",
161       first_action    => 'start',
162       second_action   => 'start',
163       require         => [Pacemaker::Resource::Service[$::nova::params::api_service_name],
164                           Pacemaker::Resource::Service[$::nova::params::scheduler_service_name]],
165     }
166     pacemaker::constraint::colocation { 'nova-scheduler-with-nova-api-colocation':
167       source  => "${::nova::params::scheduler_service_name}-clone",
168       target  => "${::nova::params::api_service_name}-clone",
169       score   => 'INFINITY',
170       require => [Pacemaker::Resource::Service[$::nova::params::api_service_name],
171                   Pacemaker::Resource::Service[$::nova::params::scheduler_service_name]],
172     }
173     pacemaker::constraint::base { 'nova-scheduler-then-nova-conductor-constraint':
174       constraint_type => 'order',
175       first_resource  => "${::nova::params::scheduler_service_name}-clone",
176       second_resource => "${::nova::params::conductor_service_name}-clone",
177       first_action    => 'start',
178       second_action   => 'start',
179       require         => [Pacemaker::Resource::Service[$::nova::params::scheduler_service_name],
180                           Pacemaker::Resource::Service[$::nova::params::conductor_service_name]],
181     }
182     pacemaker::constraint::colocation { 'nova-conductor-with-nova-scheduler-colocation':
183       source  => "${::nova::params::conductor_service_name}-clone",
184       target  => "${::nova::params::scheduler_service_name}-clone",
185       score   => 'INFINITY',
186       require => [Pacemaker::Resource::Service[$::nova::params::scheduler_service_name],
187                   Pacemaker::Resource::Service[$::nova::params::conductor_service_name]],
188     }
189
190     # Fedora doesn't know `require-all` parameter for constraints yet
191     if $::operatingsystem == 'Fedora' {
192       $redis_aodh_constraint_params = undef
193     } else {
194       $redis_aodh_constraint_params = 'require-all=false'
195     }
196     pacemaker::constraint::base { 'redis-then-aodh-evaluator-constraint':
197       constraint_type   => 'order',
198       first_resource    => 'redis-master',
199       second_resource   => "${::aodh::params::evaluator_service_name}-clone",
200       first_action      => 'promote',
201       second_action     => 'start',
202       constraint_params => $redis_aodh_constraint_params,
203       require           => [Pacemaker::Resource::Ocf['redis'],
204                             Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name]],
205     }
206     # Aodh
207     pacemaker::resource::service { $::aodh::params::evaluator_service_name :
208       clone_params => 'interleave=true',
209     }
210     pacemaker::resource::service { $::aodh::params::notifier_service_name :
211       clone_params => 'interleave=true',
212     }
213     pacemaker::resource::service { $::aodh::params::listener_service_name :
214       clone_params => 'interleave=true',
215     }
216     pacemaker::constraint::base { 'aodh-evaluator-then-aodh-notifier-constraint':
217       constraint_type => 'order',
218       first_resource  => "${::aodh::params::evaluator_service_name}-clone",
219       second_resource => "${::aodh::params::notifier_service_name}-clone",
220       first_action    => 'start',
221       second_action   => 'start',
222       require         => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
223                           Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
224     }
225     pacemaker::constraint::colocation { 'aodh-notifier-with-aodh-evaluator-colocation':
226       source  => "${::aodh::params::notifier_service_name}-clone",
227       target  => "${::aodh::params::evaluator_service_name}-clone",
228       score   => 'INFINITY',
229       require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
230                   Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
231     }
232     pacemaker::constraint::base { 'aodh-evaluator-then-aodh-listener-constraint':
233       constraint_type => 'order',
234       first_resource  => "${::aodh::params::evaluator_service_name}-clone",
235       second_resource => "${::aodh::params::listener_service_name}-clone",
236       first_action    => 'start',
237       second_action   => 'start',
238       require         => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
239                           Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
240     }
241     pacemaker::constraint::colocation { 'aodh-listener-with-aodh-evaluator-colocation':
242       source  => "${::aodh::params::listener_service_name}-clone",
243       target  => "${::aodh::params::evaluator_service_name}-clone",
244       score   => 'INFINITY',
245       require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
246                   Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
247     }
248
249     # Horizon and Keystone
250     pacemaker::resource::service { $::apache::params::service_name:
251       clone_params     => 'interleave=true',
252       verify_on_create => true,
253       require          => [File['/etc/keystone/ssl/certs/ca.pem'],
254       File['/etc/keystone/ssl/private/signing_key.pem'],
255       File['/etc/keystone/ssl/certs/signing_cert.pem']],
256     }
257
258     #VSM
259     if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
260       pacemaker::resource::ocf { 'vsm-p' :
261         ocf_agent_name  => 'heartbeat:VirtualDomain',
262         resource_params => 'force_stop=true config=/var/spool/cisco/vsm/vsm_primary_deploy.xml',
263         require         => Class['n1k_vsm'],
264         meta_params     => 'resource-stickiness=INFINITY',
265       }
266       if str2bool(hiera('n1k_vsm::pacemaker_control', true)) {
267         pacemaker::resource::ocf { 'vsm-s' :
268           ocf_agent_name  => 'heartbeat:VirtualDomain',
269           resource_params => 'force_stop=true config=/var/spool/cisco/vsm/vsm_secondary_deploy.xml',
270           require         => Class['n1k_vsm'],
271           meta_params     => 'resource-stickiness=INFINITY',
272         }
273         pacemaker::constraint::colocation { 'vsm-colocation-contraint':
274           source  => 'vsm-p',
275           target  => 'vsm-s',
276           score   => '-INFINITY',
277           require => [Pacemaker::Resource::Ocf['vsm-p'],
278                       Pacemaker::Resource::Ocf['vsm-s']],
279         }
280       }
281     }
282
283   }
284
285 } #END STEP 5
286
287 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller_pacemaker', hiera('step')])
288 package_manifest{$package_manifest_name: ensure => present}