Switch Cinder Api/Scheduler/Volume to composable roles
[apex-tripleo-heat-templates.git] / puppet / manifests / overcloud_controller.pp
1 # Copyright 2014 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 include ::tripleo::packages
17 include ::tripleo::firewall
18
19 $enable_load_balancer = hiera('enable_load_balancer', true)
20
21 if hiera('step') >= 1 {
22
23   create_resources(kmod::load, hiera('kernel_modules'), {})
24   create_resources(sysctl::value, hiera('sysctl_settings'), {})
25   Exec <| tag == 'kmod::load' |>  -> Sysctl <| |>
26
27 }
28
29 if hiera('step') >= 2 {
30
31   if count(hiera('ntp::servers')) > 0 {
32     include ::ntp
33   }
34
35   include ::timezone
36
37   # MongoDB
38   if downcase(hiera('ceilometer_backend')) == 'mongodb' {
39     include ::mongodb::globals
40     include ::mongodb::client
41     include ::mongodb::server
42     # NOTE(gfidente): We need to pass the list of IPv6 addresses *with* port and
43     # without the brackets as 'members' argument for the 'mongodb_replset'
44     # resource.
45     if str2bool(hiera('mongodb::server::ipv6', false)) {
46       $mongo_node_ips_with_port_prefixed = prefix(hiera('mongo_node_ips'), '[')
47       $mongo_node_ips_with_port = suffix($mongo_node_ips_with_port_prefixed, ']:27017')
48       $mongo_node_ips_with_port_nobr = suffix(hiera('mongo_node_ips'), ':27017')
49     } else {
50       $mongo_node_ips_with_port = suffix(hiera('mongo_node_ips'), ':27017')
51       $mongo_node_ips_with_port_nobr = suffix(hiera('mongo_node_ips'), ':27017')
52     }
53     $mongo_node_string = join($mongo_node_ips_with_port, ',')
54
55     $mongodb_replset = hiera('mongodb::server::replset')
56     $ceilometer_mongodb_conn_string = "mongodb://${mongo_node_string}/ceilometer?replicaSet=${mongodb_replset}"
57     if downcase(hiera('bootstrap_nodeid')) == $::hostname {
58       mongodb_replset { $mongodb_replset :
59         members => $mongo_node_ips_with_port_nobr,
60       }
61     }
62   }
63
64   # Redis
65   $redis_node_ips = hiera('redis_node_ips')
66   $redis_master_hostname = downcase(hiera('bootstrap_nodeid'))
67
68   if $redis_master_hostname == $::hostname {
69     $slaveof = undef
70   } else {
71     $slaveof = "${redis_master_hostname} 6379"
72   }
73   class {'::redis' :
74     slaveof => $slaveof,
75   }
76
77   if count($redis_node_ips) > 1 {
78     Class['::tripleo::redis_notification'] -> Service['redis-sentinel']
79     include ::redis::sentinel
80     include ::tripleo::redis_notification
81   }
82
83   if str2bool(hiera('enable_galera', true)) {
84     $mysql_config_file = '/etc/my.cnf.d/galera.cnf'
85   } else {
86     $mysql_config_file = '/etc/my.cnf.d/server.cnf'
87   }
88   # TODO Galara
89   # FIXME: due to https://bugzilla.redhat.com/show_bug.cgi?id=1298671 we
90   # set bind-address to a hostname instead of an ip address; to move Mysql
91   # from internal_api on another network we'll have to customize both
92   # MysqlNetwork and ControllerHostnameResolveNetwork in ServiceNetMap
93   class { '::mysql::server':
94     config_file             => $mysql_config_file,
95     override_options        => {
96       'mysqld' => {
97         'bind-address'     => $::hostname,
98         'max_connections'  => hiera('mysql_max_connections'),
99         'open_files_limit' => '-1',
100       },
101     },
102     remove_default_accounts => true,
103   }
104
105   # FIXME: this should only occur on the bootstrap host (ditto for db syncs)
106   # Create all the database schemas
107   include ::nova::db::mysql
108   include ::nova::db::mysql_api
109   include ::neutron::db::mysql
110   if downcase(hiera('gnocchi_indexer_backend')) == 'mysql' {
111     include ::gnocchi::db::mysql
112   }
113   if downcase(hiera('ceilometer_backend')) == 'mysql' {
114     include ::ceilometer::db::mysql
115     include ::aodh::db::mysql
116   }
117
118   $enable_ceph = hiera('ceph_storage_count', 0) > 0 or hiera('enable_ceph_storage', false)
119
120   if $enable_ceph {
121     $mon_initial_members = downcase(hiera('ceph_mon_initial_members'))
122     if str2bool(hiera('ceph_ipv6', false)) {
123       $mon_host = hiera('ceph_mon_host_v6')
124     } else {
125       $mon_host = hiera('ceph_mon_host')
126     }
127     class { '::ceph::profile::params':
128       mon_initial_members => $mon_initial_members,
129       mon_host            => $mon_host,
130     }
131     include ::ceph::conf
132     include ::ceph::profile::mon
133   }
134
135   if str2bool(hiera('enable_ceph_storage', false)) {
136     if str2bool(hiera('ceph_osd_selinux_permissive', true)) {
137       exec { 'set selinux to permissive on boot':
138         command => "sed -ie 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config",
139         onlyif  => "test -f /etc/selinux/config && ! grep '^SELINUX=permissive' /etc/selinux/config",
140         path    => ['/usr/bin', '/usr/sbin'],
141       }
142
143       exec { 'set selinux to permissive':
144         command => 'setenforce 0',
145         onlyif  => "which setenforce && getenforce | grep -i 'enforcing'",
146         path    => ['/usr/bin', '/usr/sbin'],
147       } -> Class['ceph::profile::osd']
148     }
149
150     include ::ceph::conf
151     include ::ceph::profile::osd
152   }
153
154   if str2bool(hiera('enable_external_ceph', false)) {
155     if str2bool(hiera('ceph_ipv6', false)) {
156       $mon_host = hiera('ceph_mon_host_v6')
157     } else {
158       $mon_host = hiera('ceph_mon_host')
159     }
160     class { '::ceph::profile::params':
161       mon_host            => $mon_host,
162     }
163     include ::ceph::conf
164     include ::ceph::profile::client
165   }
166
167 } #END STEP 2
168
169 if hiera('step') >= 4 {
170
171   $nova_ipv6 = hiera('nova::use_ipv6', false)
172   if $nova_ipv6 {
173     $memcached_servers = suffix(hiera('memcache_node_ips_v6'), ':11211')
174   } else {
175     $memcached_servers = suffix(hiera('memcache_node_ips'), ':11211')
176   }
177
178   class { '::nova' :
179     memcached_servers => $memcached_servers
180   }
181   include ::nova::config
182   include ::nova::api
183   include ::nova::cert
184   include ::nova::conductor
185   include ::nova::consoleauth
186   include ::nova::network::neutron
187   include ::nova::vncproxy
188   include ::nova::scheduler
189   include ::nova::scheduler::filter
190
191   if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
192
193     # TODO(devvesa) provide non-controller ips for these services
194     $zookeeper_node_ips = hiera('neutron_api_node_ips')
195     $cassandra_node_ips = hiera('neutron_api_node_ips')
196
197     # Run zookeeper in the controller if configured
198     if hiera('enable_zookeeper_on_controller') {
199       class {'::tripleo::cluster::zookeeper':
200         zookeeper_server_ips => $zookeeper_node_ips,
201         # TODO: create a 'bind' hiera key for zookeeper
202         zookeeper_client_ip  => hiera('neutron::bind_host'),
203         zookeeper_hostnames  => hiera('controller_node_names')
204       }
205     }
206
207     # Run cassandra in the controller if configured
208     if hiera('enable_cassandra_on_controller') {
209       class {'::tripleo::cluster::cassandra':
210         cassandra_servers => $cassandra_node_ips,
211         # TODO: create a 'bind' hiera key for cassandra
212         cassandra_ip      => hiera('neutron::bind_host'),
213       }
214     }
215
216     class {'::tripleo::network::midonet::agent':
217       zookeeper_servers => $zookeeper_node_ips,
218       cassandra_seeds   => $cassandra_node_ips
219     }
220
221     class {'::tripleo::network::midonet::api':
222       zookeeper_servers    => $zookeeper_node_ips,
223       vip                  => hiera('public_virtual_ip'),
224       keystone_ip          => hiera('public_virtual_ip'),
225       keystone_admin_token => hiera('keystone::admin_token'),
226       # TODO: create a 'bind' hiera key for api
227       bind_address         => hiera('neutron::bind_host'),
228       admin_password       => hiera('admin_password')
229     }
230
231     # TODO: find a way to get an empty list from hiera
232     class {'::neutron':
233       service_plugins => []
234     }
235
236   }
237   else {
238
239     # ML2 plugin
240     include ::neutron
241   }
242
243   include ::neutron::config
244   include ::neutron::server
245   include ::neutron::server::notifications
246
247   # If the value of core plugin is set to 'nuage' or'opencontrail' or 'plumgrid',
248   # include nuage or opencontrail or plumgrid core plugins
249   # else use the default value of 'ml2'
250   if hiera('neutron::core_plugin') == 'neutron.plugins.nuage.plugin.NuagePlugin' {
251     include ::neutron::plugins::nuage
252   } elsif hiera('neutron::core_plugin') == 'neutron_plugin_contrail.plugins.opencontrail.contrail_plugin.NeutronPluginContrailCoreV2' {
253     include ::neutron::plugins::opencontrail
254   }
255   elsif hiera('neutron::core_plugin') == 'networking_plumgrid.neutron.plugins.plugin.NeutronPluginPLUMgridV2' {
256     class { '::neutron::plugins::plumgrid' :
257       connection                   => hiera('neutron::server::database_connection'),
258       controller_priv_host         => hiera('keystone_admin_api_vip'),
259       admin_password               => hiera('admin_password'),
260       metadata_proxy_shared_secret => hiera('nova::api::neutron_metadata_proxy_shared_secret'),
261     }
262   } else {
263
264     # If the value of core plugin is set to 'midonet',
265     # skip all the ML2 configuration
266     if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
267
268       class {'::neutron::plugins::midonet':
269         midonet_api_ip    => hiera('public_virtual_ip'),
270         keystone_tenant   => hiera('neutron::server::auth_tenant'),
271         keystone_password => hiera('neutron::server::password')
272       }
273     } else {
274
275       include ::neutron::plugins::ml2
276       include ::neutron::agents::ml2::ovs
277
278       if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
279         include ::neutron::plugins::ml2::cisco::nexus1000v
280
281         class { '::neutron::agents::n1kv_vem':
282           n1kv_source  => hiera('n1kv_vem_source', undef),
283           n1kv_version => hiera('n1kv_vem_version', undef),
284         }
285
286         class { '::n1k_vsm':
287           n1kv_source       => hiera('n1kv_vsm_source', undef),
288           n1kv_version      => hiera('n1kv_vsm_version', undef),
289           pacemaker_control => false,
290         }
291       }
292
293       if 'cisco_ucsm' in hiera('neutron::plugins::ml2::mechanism_drivers') {
294         include ::neutron::plugins::ml2::cisco::ucsm
295       }
296       if 'cisco_nexus' in hiera('neutron::plugins::ml2::mechanism_drivers') {
297         include ::neutron::plugins::ml2::cisco::nexus
298         include ::neutron::plugins::ml2::cisco::type_nexus_vxlan
299       }
300
301       if 'bsn_ml2' in hiera('neutron::plugins::ml2::mechanism_drivers') {
302         include ::neutron::plugins::ml2::bigswitch::restproxy
303         include ::neutron::agents::bigswitch
304       }
305       Service['neutron-server'] -> Service['neutron-ovs-agent-service']
306     }
307
308     Service['neutron-server'] -> Service['neutron-metadata']
309   }
310
311   if $enable_ceph {
312     $ceph_pools = hiera('ceph_pools')
313     ceph::pool { $ceph_pools :
314       pg_num  => hiera('ceph::profile::params::osd_pool_default_pg_num'),
315       pgp_num => hiera('ceph::profile::params::osd_pool_default_pgp_num'),
316       size    => hiera('ceph::profile::params::osd_pool_default_size'),
317     }
318   }
319
320   # swift storage
321   if str2bool(hiera('enable_swift_storage', true)) {
322     class { '::swift::storage::all':
323       mount_check => str2bool(hiera('swift_mount_check')),
324     }
325     if(!defined(File['/srv/node'])) {
326       file { '/srv/node':
327         ensure  => directory,
328         owner   => 'swift',
329         group   => 'swift',
330         require => Package['openstack-swift'],
331       }
332     }
333     $swift_components = ['account', 'container', 'object']
334     swift::storage::filter::recon { $swift_components : }
335     swift::storage::filter::healthcheck { $swift_components : }
336   }
337
338   # Ceilometer
339   $ceilometer_backend = downcase(hiera('ceilometer_backend'))
340   case $ceilometer_backend {
341     /mysql/ : {
342       $ceilometer_database_connection = hiera('ceilometer_mysql_conn_string')
343     }
344     default : {
345       $ceilometer_database_connection = $ceilometer_mongodb_conn_string
346     }
347   }
348   include ::ceilometer
349   include ::ceilometer::config
350   include ::ceilometer::api
351   include ::ceilometer::agent::notification
352   include ::ceilometer::agent::central
353   include ::ceilometer::expirer
354   include ::ceilometer::collector
355   include ::ceilometer::agent::auth
356   include ::ceilometer::dispatcher::gnocchi
357   class { '::ceilometer::db' :
358     database_connection => $ceilometer_database_connection,
359   }
360
361   Cron <| title == 'ceilometer-expirer' |> { command => "sleep $((\$(od -A n -t d -N 3 /dev/urandom) % 86400)) && ${::ceilometer::params::expirer_command}" }
362
363   # Aodh
364   class { '::aodh' :
365     database_connection => $ceilometer_database_connection,
366   }
367   include ::aodh::db::sync
368   # To manage the upgrade:
369   Exec['ceilometer-dbsync'] -> Exec['aodh-db-sync']
370   include ::aodh::auth
371   include ::aodh::api
372   include ::aodh::wsgi::apache
373   include ::aodh::evaluator
374   include ::aodh::notifier
375   include ::aodh::listener
376   include ::aodh::client
377
378   # Horizon
379   include ::apache::mod::remoteip
380   if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
381     $_profile_support = 'cisco'
382   } else {
383     $_profile_support = 'None'
384   }
385   $neutron_options   = {'profile_support' => $_profile_support }
386
387   $memcached_ipv6 = hiera('memcached_ipv6', false)
388   if $memcached_ipv6 {
389     $horizon_memcached_servers = hiera('memcache_node_ips_v6', '[::1]')
390   } else {
391     $horizon_memcached_servers = hiera('memcache_node_ips', '127.0.0.1')
392   }
393
394   class { '::horizon':
395     cache_server_ip => $horizon_memcached_servers,
396     neutron_options => $neutron_options,
397   }
398
399   # Gnocchi
400   $gnocchi_database_connection = hiera('gnocchi_mysql_conn_string')
401   class { '::gnocchi':
402     database_connection => $gnocchi_database_connection,
403   }
404   include ::gnocchi::api
405   include ::gnocchi::wsgi::apache
406   include ::gnocchi::client
407   include ::gnocchi::db::sync
408   include ::gnocchi::storage
409   include ::gnocchi::metricd
410   include ::gnocchi::statsd
411   $gnocchi_backend = downcase(hiera('gnocchi_backend', 'swift'))
412   case $gnocchi_backend {
413       'swift': { include ::gnocchi::storage::swift }
414       'file': { include ::gnocchi::storage::file }
415       'rbd': { include ::gnocchi::storage::ceph }
416       default: { fail('Unrecognized gnocchi_backend parameter.') }
417   }
418
419   $snmpd_user = hiera('snmpd_readonly_user_name')
420   snmp::snmpv3_user { $snmpd_user:
421     authtype => 'MD5',
422     authpass => hiera('snmpd_readonly_user_password'),
423   }
424   class { '::snmp':
425     agentaddress => ['udp:161','udp6:[::1]:161'],
426     snmpd_config => [ join(['createUser ', hiera('snmpd_readonly_user_name'), ' MD5 "', hiera('snmpd_readonly_user_password'), '"']), join(['rouser ', hiera('snmpd_readonly_user_name')]), 'proc  cron', 'includeAllDisks  10%', 'master agentx', 'trapsink localhost public', 'iquerySecName internalUser', 'rouser internalUser', 'defaultMonitors yes', 'linkUpDownNotifications yes' ],
427   }
428
429   hiera_include('controller_classes')
430
431 } #END STEP 4
432
433 if hiera('step') >= 5 {
434   $nova_enable_db_purge = hiera('nova_enable_db_purge', true)
435
436   if $nova_enable_db_purge {
437     include ::nova::cron::archive_deleted_rows
438   }
439 } #END STEP 5
440
441 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller', hiera('step')])
442 package_manifest{$package_manifest_name: ensure => present}