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