Merge "Stop passing charset=utf8 for neutron database connection option"
[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     # Fedora doesn't know `require-all` parameter for constraints yet
103     if $::operatingsystem == 'Fedora' {
104       $redis_aodh_constraint_params = undef
105     } else {
106       $redis_aodh_constraint_params = 'require-all=false'
107     }
108     pacemaker::constraint::base { 'redis-then-aodh-evaluator-constraint':
109       constraint_type   => 'order',
110       first_resource    => 'redis-master',
111       second_resource   => "${::aodh::params::evaluator_service_name}-clone",
112       first_action      => 'promote',
113       second_action     => 'start',
114       constraint_params => $redis_aodh_constraint_params,
115       require           => [Pacemaker::Resource::Ocf['redis'],
116                             Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name]],
117     }
118     # Aodh
119     pacemaker::resource::service { $::aodh::params::evaluator_service_name :
120       clone_params => 'interleave=true',
121     }
122     pacemaker::resource::service { $::aodh::params::notifier_service_name :
123       clone_params => 'interleave=true',
124     }
125     pacemaker::resource::service { $::aodh::params::listener_service_name :
126       clone_params => 'interleave=true',
127     }
128     pacemaker::constraint::base { 'aodh-evaluator-then-aodh-notifier-constraint':
129       constraint_type => 'order',
130       first_resource  => "${::aodh::params::evaluator_service_name}-clone",
131       second_resource => "${::aodh::params::notifier_service_name}-clone",
132       first_action    => 'start',
133       second_action   => 'start',
134       require         => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
135                           Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
136     }
137     pacemaker::constraint::colocation { 'aodh-notifier-with-aodh-evaluator-colocation':
138       source  => "${::aodh::params::notifier_service_name}-clone",
139       target  => "${::aodh::params::evaluator_service_name}-clone",
140       score   => 'INFINITY',
141       require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
142                   Pacemaker::Resource::Service[$::aodh::params::notifier_service_name]],
143     }
144     pacemaker::constraint::base { 'aodh-evaluator-then-aodh-listener-constraint':
145       constraint_type => 'order',
146       first_resource  => "${::aodh::params::evaluator_service_name}-clone",
147       second_resource => "${::aodh::params::listener_service_name}-clone",
148       first_action    => 'start',
149       second_action   => 'start',
150       require         => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
151                           Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
152     }
153     pacemaker::constraint::colocation { 'aodh-listener-with-aodh-evaluator-colocation':
154       source  => "${::aodh::params::listener_service_name}-clone",
155       target  => "${::aodh::params::evaluator_service_name}-clone",
156       score   => 'INFINITY',
157       require => [Pacemaker::Resource::Service[$::aodh::params::evaluator_service_name],
158                   Pacemaker::Resource::Service[$::aodh::params::listener_service_name]],
159     }
160
161     #VSM
162     if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
163       pacemaker::resource::ocf { 'vsm-p' :
164         ocf_agent_name  => 'heartbeat:VirtualDomain',
165         resource_params => 'force_stop=true config=/var/spool/cisco/vsm/vsm_primary_deploy.xml',
166         require         => Class['n1k_vsm'],
167         meta_params     => 'resource-stickiness=INFINITY',
168       }
169       if str2bool(hiera('n1k_vsm::pacemaker_control', true)) {
170         pacemaker::resource::ocf { 'vsm-s' :
171           ocf_agent_name  => 'heartbeat:VirtualDomain',
172           resource_params => 'force_stop=true config=/var/spool/cisco/vsm/vsm_secondary_deploy.xml',
173           require         => Class['n1k_vsm'],
174           meta_params     => 'resource-stickiness=INFINITY',
175         }
176         pacemaker::constraint::colocation { 'vsm-colocation-contraint':
177           source  => 'vsm-p',
178           target  => 'vsm-s',
179           score   => '-INFINITY',
180           require => [Pacemaker::Resource::Ocf['vsm-p'],
181                       Pacemaker::Resource::Ocf['vsm-s']],
182         }
183       }
184     }
185
186   }
187
188 } #END STEP 5
189
190 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller_pacemaker', hiera('step')])
191 package_manifest{$package_manifest_name: ensure => present}