Merge "Explicitly set nova and neutron host on controllers"
[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   if $pacemaker_master {
91
92     pacemaker::constraint::base { 'openstack-core-then-httpd-constraint':
93       constraint_type => 'order',
94       first_resource  => 'openstack-core-clone',
95       second_resource => "${::apache::params::service_name}-clone",
96       first_action    => 'start',
97       second_action   => 'start',
98       require         => [Pacemaker::Resource::Service[$::apache::params::service_name],
99                           Pacemaker::Resource::Ocf['openstack-core']],
100     }
101
102     # Nova
103     pacemaker::constraint::base { 'keystone-then-nova-consoleauth-constraint':
104       constraint_type => 'order',
105       first_resource  => 'openstack-core-clone',
106       second_resource => "${::nova::params::consoleauth_service_name}-clone",
107       first_action    => 'start',
108       second_action   => 'start',
109       require         => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
110                           Pacemaker::Resource::Ocf['openstack-core']],
111     }
112     pacemaker::constraint::colocation { 'nova-consoleauth-with-openstack-core':
113       source  => "${::nova::params::consoleauth_service_name}-clone",
114       target  => 'openstack-core-clone',
115       score   => 'INFINITY',
116       require => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
117                   Pacemaker::Resource::Ocf['openstack-core']],
118     }
119     pacemaker::constraint::base { 'nova-consoleauth-then-nova-vncproxy-constraint':
120       constraint_type => 'order',
121       first_resource  => "${::nova::params::consoleauth_service_name}-clone",
122       second_resource => "${::nova::params::vncproxy_service_name}-clone",
123       first_action    => 'start',
124       second_action   => 'start',
125       require         => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
126                           Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name]],
127     }
128     pacemaker::constraint::colocation { 'nova-vncproxy-with-nova-consoleauth-colocation':
129       source  => "${::nova::params::vncproxy_service_name}-clone",
130       target  => "${::nova::params::consoleauth_service_name}-clone",
131       score   => 'INFINITY',
132       require => [Pacemaker::Resource::Service[$::nova::params::consoleauth_service_name],
133                   Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name]],
134     }
135     pacemaker::constraint::base { 'nova-vncproxy-then-nova-api-constraint':
136       constraint_type => 'order',
137       first_resource  => "${::nova::params::vncproxy_service_name}-clone",
138       second_resource => "${::nova::params::api_service_name}-clone",
139       first_action    => 'start',
140       second_action   => 'start',
141       require         => [Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name],
142                           Pacemaker::Resource::Service[$::nova::params::api_service_name]],
143     }
144     pacemaker::constraint::colocation { 'nova-api-with-nova-vncproxy-colocation':
145       source  => "${::nova::params::api_service_name}-clone",
146       target  => "${::nova::params::vncproxy_service_name}-clone",
147       score   => 'INFINITY',
148       require => [Pacemaker::Resource::Service[$::nova::params::vncproxy_service_name],
149                   Pacemaker::Resource::Service[$::nova::params::api_service_name]],
150     }
151     pacemaker::constraint::base { 'nova-api-then-nova-scheduler-constraint':
152       constraint_type => 'order',
153       first_resource  => "${::nova::params::api_service_name}-clone",
154       second_resource => "${::nova::params::scheduler_service_name}-clone",
155       first_action    => 'start',
156       second_action   => 'start',
157       require         => [Pacemaker::Resource::Service[$::nova::params::api_service_name],
158                           Pacemaker::Resource::Service[$::nova::params::scheduler_service_name]],
159     }
160     pacemaker::constraint::colocation { 'nova-scheduler-with-nova-api-colocation':
161       source  => "${::nova::params::scheduler_service_name}-clone",
162       target  => "${::nova::params::api_service_name}-clone",
163       score   => 'INFINITY',
164       require => [Pacemaker::Resource::Service[$::nova::params::api_service_name],
165                   Pacemaker::Resource::Service[$::nova::params::scheduler_service_name]],
166     }
167     pacemaker::constraint::base { 'nova-scheduler-then-nova-conductor-constraint':
168       constraint_type => 'order',
169       first_resource  => "${::nova::params::scheduler_service_name}-clone",
170       second_resource => "${::nova::params::conductor_service_name}-clone",
171       first_action    => 'start',
172       second_action   => 'start',
173       require         => [Pacemaker::Resource::Service[$::nova::params::scheduler_service_name],
174                           Pacemaker::Resource::Service[$::nova::params::conductor_service_name]],
175     }
176     pacemaker::constraint::colocation { 'nova-conductor-with-nova-scheduler-colocation':
177       source  => "${::nova::params::conductor_service_name}-clone",
178       target  => "${::nova::params::scheduler_service_name}-clone",
179       score   => 'INFINITY',
180       require => [Pacemaker::Resource::Service[$::nova::params::scheduler_service_name],
181                   Pacemaker::Resource::Service[$::nova::params::conductor_service_name]],
182     }
183
184     # Fedora doesn't know `require-all` parameter for constraints yet
185     if $::operatingsystem == 'Fedora' {
186       $redis_aodh_constraint_params = undef
187     } else {
188       $redis_aodh_constraint_params = 'require-all=false'
189     }
190     pacemaker::constraint::base { 'redis-then-aodh-evaluator-constraint':
191       constraint_type   => 'order',
192       first_resource    => 'redis-master',
193       second_resource   => "${::aodh::params::evaluator_service_name}-clone",
194       first_action      => 'promote',
195       second_action     => 'start',
196       constraint_params => $redis_aodh_constraint_params,
197       require           => [Pacemaker::Resource::Ocf['redis'],
198                             Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name]],
199     }
200     # Aodh
201     pacemaker::resource::service { $::aodh::params::evaluator_service_name :
202       clone_params => 'interleave=true',
203     }
204     pacemaker::resource::service { $::aodh::params::notifier_service_name :
205       clone_params => 'interleave=true',
206     }
207     pacemaker::resource::service { $::aodh::params::listener_service_name :
208       clone_params => 'interleave=true',
209     }
210     pacemaker::constraint::base { 'aodh-evaluator-then-aodh-notifier-constraint':
211       constraint_type => 'order',
212       first_resource  => "${::aodh::params::evaluator_service_name}-clone",
213       second_resource => "${::aodh::params::notifier_service_name}-clone",
214       first_action    => 'start',
215       second_action   => 'start',
216       require         => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
217                           Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
218     }
219     pacemaker::constraint::colocation { 'aodh-notifier-with-aodh-evaluator-colocation':
220       source  => "${::aodh::params::notifier_service_name}-clone",
221       target  => "${::aodh::params::evaluator_service_name}-clone",
222       score   => 'INFINITY',
223       require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
224                   Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
225     }
226     pacemaker::constraint::base { 'aodh-evaluator-then-aodh-listener-constraint':
227       constraint_type => 'order',
228       first_resource  => "${::aodh::params::evaluator_service_name}-clone",
229       second_resource => "${::aodh::params::listener_service_name}-clone",
230       first_action    => 'start',
231       second_action   => 'start',
232       require         => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
233                           Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
234     }
235     pacemaker::constraint::colocation { 'aodh-listener-with-aodh-evaluator-colocation':
236       source  => "${::aodh::params::listener_service_name}-clone",
237       target  => "${::aodh::params::evaluator_service_name}-clone",
238       score   => 'INFINITY',
239       require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
240                   Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
241     }
242
243     #VSM
244     if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
245       pacemaker::resource::ocf { 'vsm-p' :
246         ocf_agent_name  => 'heartbeat:VirtualDomain',
247         resource_params => 'force_stop=true config=/var/spool/cisco/vsm/vsm_primary_deploy.xml',
248         require         => Class['n1k_vsm'],
249         meta_params     => 'resource-stickiness=INFINITY',
250       }
251       if str2bool(hiera('n1k_vsm::pacemaker_control', true)) {
252         pacemaker::resource::ocf { 'vsm-s' :
253           ocf_agent_name  => 'heartbeat:VirtualDomain',
254           resource_params => 'force_stop=true config=/var/spool/cisco/vsm/vsm_secondary_deploy.xml',
255           require         => Class['n1k_vsm'],
256           meta_params     => 'resource-stickiness=INFINITY',
257         }
258         pacemaker::constraint::colocation { 'vsm-colocation-contraint':
259           source  => 'vsm-p',
260           target  => 'vsm-s',
261           score   => '-INFINITY',
262           require => [Pacemaker::Resource::Ocf['vsm-p'],
263                       Pacemaker::Resource::Ocf['vsm-s']],
264         }
265       }
266     }
267
268   }
269
270 } #END STEP 5
271
272 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller_pacemaker', hiera('step')])
273 package_manifest{$package_manifest_name: ensure => present}