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