Merge "Wire Neutron ML2 plugin and OVS agent settings as arrays"
[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(sysctl::value, hiera('sysctl_settings'), {})
24
25   $controller_node_ips = split(hiera('controller_node_ips'), ',')
26
27   if $enable_load_balancer {
28     class { '::tripleo::loadbalancer' :
29       controller_hosts => $controller_node_ips,
30       manage_vip       => true,
31     }
32   }
33
34 }
35
36 if hiera('step') >= 2 {
37
38   if count(hiera('ntp::servers')) > 0 {
39     include ::ntp
40   }
41
42   # MongoDB
43   if downcase(hiera('ceilometer_backend')) == 'mongodb' {
44     include ::mongodb::globals
45
46     include ::mongodb::server
47     $mongo_node_ips_with_port = suffix(hiera('mongo_node_ips'), ':27017')
48     $mongo_node_string = join($mongo_node_ips_with_port, ',')
49
50     $mongodb_replset = hiera('mongodb::server::replset')
51     $ceilometer_mongodb_conn_string = "mongodb://${mongo_node_string}/ceilometer?replicaSet=${mongodb_replset}"
52     if downcase(hiera('bootstrap_nodeid')) == $::hostname {
53       mongodb_replset { $mongodb_replset :
54         members => $mongo_node_ips_with_port,
55       }
56     }
57   }
58
59   # Redis
60   $redis_node_ips = hiera('redis_node_ips')
61   $redis_master_hostname = downcase(hiera('bootstrap_nodeid'))
62
63   if $redis_master_hostname == $::hostname {
64     $slaveof = undef
65   } else {
66     $slaveof = "${redis_master_hostname} 6379"
67   }
68   class {'::redis' :
69     slaveof => $slaveof,
70   }
71
72   if count($redis_node_ips) > 1 {
73     Class['::tripleo::redis_notification'] -> Service['redis-sentinel']
74     include ::redis::sentinel
75     include ::tripleo::redis_notification
76   }
77
78   if str2bool(hiera('enable_galera', true)) {
79     $mysql_config_file = '/etc/my.cnf.d/galera.cnf'
80   } else {
81     $mysql_config_file = '/etc/my.cnf.d/server.cnf'
82   }
83   # TODO Galara
84   class { '::mysql::server':
85     config_file             => $mysql_config_file,
86     override_options        => {
87       'mysqld' => {
88         'bind-address'     => hiera('mysql_bind_host'),
89         'max_connections'  => hiera('mysql_max_connections'),
90         'open_files_limit' => '-1',
91       },
92     },
93     remove_default_accounts => true,
94   }
95
96   # FIXME: this should only occur on the bootstrap host (ditto for db syncs)
97   # Create all the database schemas
98   include ::keystone::db::mysql
99   include ::glance::db::mysql
100   include ::nova::db::mysql
101   include ::neutron::db::mysql
102   include ::cinder::db::mysql
103   include ::heat::db::mysql
104   if downcase(hiera('ceilometer_backend')) == 'mysql' {
105     include ::ceilometer::db::mysql
106   }
107
108   $rabbit_nodes = hiera('rabbit_node_ips')
109   if count($rabbit_nodes) > 1 {
110     class { '::rabbitmq':
111       config_cluster          => true,
112       cluster_nodes           => $rabbit_nodes,
113       tcp_keepalive           => false,
114       config_kernel_variables => hiera('rabbitmq_kernel_variables'),
115       config_variables        => hiera('rabbitmq_config_variables'),
116       environment_variables   => hiera('rabbitmq_environment'),
117     }
118     rabbitmq_policy { 'ha-all@/':
119       pattern    => '^(?!amq\.).*',
120       definition => {
121         'ha-mode' => 'all',
122       },
123     }
124   } else {
125     include ::rabbitmq
126   }
127
128   # pre-install swift here so we can build rings
129   include ::swift
130
131   $enable_ceph = hiera('ceph_storage_count', 0) > 0
132
133   if $enable_ceph {
134     class { '::ceph::profile::params':
135       mon_initial_members => downcase(hiera('ceph_mon_initial_members')),
136     }
137     include ::ceph::profile::mon
138   }
139
140   if str2bool(hiera('enable_ceph_storage', false)) {
141     if str2bool(hiera('ceph_osd_selinux_permissive', true)) {
142       exec { 'set selinux to permissive on boot':
143         command => "sed -ie 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config",
144         onlyif  => "test -f /etc/selinux/config && ! grep '^SELINUX=permissive' /etc/selinux/config",
145         path    => ['/usr/bin', '/usr/sbin'],
146       }
147
148       exec { 'set selinux to permissive':
149         command => 'setenforce 0',
150         onlyif  => "which setenforce && getenforce | grep -i 'enforcing'",
151         path    => ['/usr/bin', '/usr/sbin'],
152       } -> Class['ceph::profile::osd']
153     }
154
155     include ::ceph::profile::osd
156   }
157
158   if str2bool(hiera('enable_external_ceph', false)) {
159     include ::ceph::profile::client
160   }
161
162 } #END STEP 2
163
164 if hiera('step') >= 3 {
165
166   include ::keystone
167   include ::keystone::roles::admin
168   include ::keystone::endpoint
169
170   #TODO: need a cleanup-keystone-tokens.sh solution here
171   keystone_config {
172     'ec2/driver': value => 'keystone.contrib.ec2.backends.sql.Ec2';
173   }
174   file { [ '/etc/keystone/ssl', '/etc/keystone/ssl/certs', '/etc/keystone/ssl/private' ]:
175     ensure  => 'directory',
176     owner   => 'keystone',
177     group   => 'keystone',
178     require => Package['keystone'],
179   }
180   file { '/etc/keystone/ssl/certs/signing_cert.pem':
181     content => hiera('keystone_signing_certificate'),
182     owner   => 'keystone',
183     group   => 'keystone',
184     notify  => Service['keystone'],
185     require => File['/etc/keystone/ssl/certs'],
186   }
187   file { '/etc/keystone/ssl/private/signing_key.pem':
188     content => hiera('keystone_signing_key'),
189     owner   => 'keystone',
190     group   => 'keystone',
191     notify  => Service['keystone'],
192     require => File['/etc/keystone/ssl/private'],
193   }
194   file { '/etc/keystone/ssl/certs/ca.pem':
195     content => hiera('keystone_ca_certificate'),
196     owner   => 'keystone',
197     group   => 'keystone',
198     notify  => Service['keystone'],
199     require => File['/etc/keystone/ssl/certs'],
200   }
201
202   $glance_backend = downcase(hiera('glance_backend', 'swift'))
203   case $glance_backend {
204       'swift': { $backend_store = 'glance.store.swift.Store' }
205       'file': { $backend_store = 'glance.store.filesystem.Store' }
206       'rbd': { $backend_store = 'glance.store.rbd.Store' }
207       default: { fail('Unrecognized glance_backend parameter.') }
208   }
209   $http_store = ['glance.store.http.Store']
210   $glance_store = concat($http_store, $backend_store)
211
212   # TODO: notifications, scrubber, etc.
213   include ::glance
214   class { '::glance::api':
215     known_stores => $glance_store,
216   }
217   include ::glance::registry
218   include join(['::glance::backend::', $glance_backend])
219
220   class { '::nova' :
221     memcached_servers => suffix(hiera('memcache_node_ips'), ':11211'),
222   }
223   include ::nova::config
224   include ::nova::api
225   include ::nova::cert
226   include ::nova::conductor
227   include ::nova::consoleauth
228   include ::nova::network::neutron
229   include ::nova::vncproxy
230   include ::nova::scheduler
231   include ::nova::scheduler::filter
232
233   include ::neutron
234   include ::neutron::server
235   include ::neutron::server::notifications
236
237   # If the value of core plugin is set to 'nuage',
238   # include nuage core plugin,
239   # else use the default value of 'ml2'
240   if hiera('neutron::core_plugin') == 'neutron.plugins.nuage.plugin.NuagePlugin' {
241     include ::neutron::plugins::nuage
242   } else {
243     include ::neutron::agents::l3
244     include ::neutron::agents::dhcp
245     include ::neutron::agents::metadata
246
247     file { '/etc/neutron/dnsmasq-neutron.conf':
248       content => hiera('neutron_dnsmasq_options'),
249       owner   => 'neutron',
250       group   => 'neutron',
251       notify  => Service['neutron-dhcp-service'],
252       require => Package['neutron'],
253     }
254
255     include ::neutron::plugins::ml2
256     include ::neutron::agents::ml2::ovs
257
258     if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
259       include ::neutron::plugins::ml2::cisco::nexus1000v
260
261       class { '::neutron::agents::n1kv_vem':
262         n1kv_source  => hiera('n1kv_vem_source', undef),
263         n1kv_version => hiera('n1kv_vem_version', undef),
264       }
265
266       class { '::n1k_vsm':
267         n1kv_source       => hiera('n1kv_vsm_source', undef),
268         n1kv_version      => hiera('n1kv_vsm_version', undef),
269         pacemaker_control => false,
270       }
271     }
272
273     if 'cisco_ucsm' in hiera('neutron::plugins::ml2::mechanism_drivers') {
274       include ::neutron::plugins::ml2::cisco::ucsm
275     }
276     if 'cisco_nexus' in hiera('neutron::plugins::ml2::mechanism_drivers') {
277       include ::neutron::plugins::ml2::cisco::nexus
278       include ::neutron::plugins::ml2::cisco::type_nexus_vxlan
279     }
280
281     if hiera('neutron_enable_bigswitch_ml2', false) {
282       include ::neutron::plugins::ml2::bigswitch::restproxy
283     }
284     neutron_l3_agent_config {
285       'DEFAULT/ovs_use_veth': value => hiera('neutron_ovs_use_veth', false);
286     }
287     neutron_dhcp_agent_config {
288       'DEFAULT/ovs_use_veth': value => hiera('neutron_ovs_use_veth', false);
289     }
290
291     Service['neutron-server'] -> Service['neutron-dhcp-service']
292     Service['neutron-server'] -> Service['neutron-l3']
293     Service['neutron-server'] -> Service['neutron-ovs-agent-service']
294     Service['neutron-server'] -> Service['neutron-metadata']
295   }
296
297   include ::cinder
298   include ::cinder::api
299   include ::cinder::glance
300   include ::cinder::scheduler
301   include ::cinder::volume
302   class { '::cinder::setup_test_volume':
303     size => join([hiera('cinder_lvm_loop_device_size'), 'M']),
304   }
305
306   $cinder_enable_iscsi = hiera('cinder_enable_iscsi_backend', true)
307   if $cinder_enable_iscsi {
308     $cinder_iscsi_backend = 'tripleo_iscsi'
309
310     cinder::backend::iscsi { $cinder_iscsi_backend :
311       iscsi_ip_address => hiera('cinder_iscsi_ip_address'),
312       iscsi_helper     => hiera('cinder_iscsi_helper'),
313     }
314   }
315
316   if $enable_ceph {
317
318     $ceph_pools = hiera('ceph_pools')
319     ceph::pool { $ceph_pools :
320       pg_num  => hiera('ceph::profile::params::osd_pool_default_pg_num'),
321       pgp_num => hiera('ceph::profile::params::osd_pool_default_pgp_num'),
322       size    => hiera('ceph::profile::params::osd_pool_default_size'),
323     }
324
325     $cinder_pool_requires = [Ceph::Pool[hiera('cinder_rbd_pool_name')]]
326
327   } else {
328     $cinder_pool_requires = []
329   }
330
331   if hiera('cinder_enable_rbd_backend', false) {
332     $cinder_rbd_backend = 'tripleo_ceph'
333
334     cinder::backend::rbd { $cinder_rbd_backend :
335       rbd_pool        => hiera('cinder_rbd_pool_name'),
336       rbd_user        => hiera('ceph_client_user_name'),
337       rbd_secret_uuid => hiera('ceph::profile::params::fsid'),
338       require         => $cinder_pool_requires,
339     }
340   }
341
342   if hiera('cinder_enable_netapp_backend', false) {
343     $cinder_netapp_backend = hiera('cinder::backend::netapp::title')
344
345     cinder_config {
346       "${cinder_netapp_backend}/host": value => 'hostgroup';
347     }
348
349     if hiera('cinder::backend::netapp::nfs_shares', undef) {
350       $cinder_netapp_nfs_shares = split(hiera('cinder::backend::netapp::nfs_shares', undef), ',')
351     }
352
353     cinder::backend::netapp { $cinder_netapp_backend :
354       netapp_login                 => hiera('cinder::backend::netapp::netapp_login', undef),
355       netapp_password              => hiera('cinder::backend::netapp::netapp_password', undef),
356       netapp_server_hostname       => hiera('cinder::backend::netapp::netapp_server_hostname', undef),
357       netapp_server_port           => hiera('cinder::backend::netapp::netapp_server_port', undef),
358       netapp_size_multiplier       => hiera('cinder::backend::netapp::netapp_size_multiplier', undef),
359       netapp_storage_family        => hiera('cinder::backend::netapp::netapp_storage_family', undef),
360       netapp_storage_protocol      => hiera('cinder::backend::netapp::netapp_storage_protocol', undef),
361       netapp_transport_type        => hiera('cinder::backend::netapp::netapp_transport_type', undef),
362       netapp_vfiler                => hiera('cinder::backend::netapp::netapp_vfiler', undef),
363       netapp_volume_list           => hiera('cinder::backend::netapp::netapp_volume_list', undef),
364       netapp_vserver               => hiera('cinder::backend::netapp::netapp_vserver', undef),
365       netapp_partner_backend_name  => hiera('cinder::backend::netapp::netapp_partner_backend_name', undef),
366       nfs_shares                   => $cinder_netapp_nfs_shares,
367       nfs_shares_config            => hiera('cinder::backend::netapp::nfs_shares_config', undef),
368       netapp_copyoffload_tool_path => hiera('cinder::backend::netapp::netapp_copyoffload_tool_path', undef),
369       netapp_controller_ips        => hiera('cinder::backend::netapp::netapp_controller_ips', undef),
370       netapp_sa_password           => hiera('cinder::backend::netapp::netapp_sa_password', undef),
371       netapp_storage_pools         => hiera('cinder::backend::netapp::netapp_storage_pools', undef),
372       netapp_eseries_host_type     => hiera('cinder::backend::netapp::netapp_eseries_host_type', undef),
373       netapp_webservice_path       => hiera('cinder::backend::netapp::netapp_webservice_path', undef),
374     }
375   }
376
377   if hiera('cinder_enable_nfs_backend', false) {
378     $cinder_nfs_backend = 'tripleo_nfs'
379
380     if str2bool($::selinux) {
381       selboolean { 'virt_use_nfs':
382         value      => on,
383         persistent => true,
384       } -> Package['nfs-utils']
385     }
386
387     package {'nfs-utils': } ->
388     cinder::backend::nfs { $cinder_nfs_backend :
389       nfs_servers       => hiera('cinder_nfs_servers'),
390       nfs_mount_options => hiera('cinder_nfs_mount_options',''),
391       nfs_shares_config => '/etc/cinder/shares-nfs.conf',
392     }
393   }
394
395   $cinder_enabled_backends = delete_undef_values([$cinder_iscsi_backend, $cinder_rbd_backend, $cinder_netapp_backend, $cinder_nfs_backend])
396   class { '::cinder::backends' :
397     enabled_backends => $cinder_enabled_backends,
398   }
399
400   # swift proxy
401   include ::memcached
402   include ::swift::proxy
403   include ::swift::proxy::proxy_logging
404   include ::swift::proxy::healthcheck
405   include ::swift::proxy::cache
406   include ::swift::proxy::keystone
407   include ::swift::proxy::authtoken
408   include ::swift::proxy::staticweb
409   include ::swift::proxy::ratelimit
410   include ::swift::proxy::catch_errors
411   include ::swift::proxy::tempurl
412   include ::swift::proxy::formpost
413
414   # swift storage
415   if str2bool(hiera('enable_swift_storage', true)) {
416     class { '::swift::storage::all':
417       mount_check => str2bool(hiera('swift_mount_check')),
418     }
419     if(!defined(File['/srv/node'])) {
420       file { '/srv/node':
421         ensure  => directory,
422         owner   => 'swift',
423         group   => 'swift',
424         require => Package['openstack-swift'],
425       }
426     }
427     $swift_components = ['account', 'container', 'object']
428     swift::storage::filter::recon { $swift_components : }
429     swift::storage::filter::healthcheck { $swift_components : }
430   }
431
432   # Ceilometer
433   $ceilometer_backend = downcase(hiera('ceilometer_backend'))
434   case $ceilometer_backend {
435     /mysql/ : {
436       $ceilometer_database_connection = hiera('ceilometer_mysql_conn_string')
437     }
438     default : {
439       $ceilometer_database_connection = $ceilometer_mongodb_conn_string
440     }
441   }
442   include ::ceilometer
443   include ::ceilometer::config
444   include ::ceilometer::api
445   include ::ceilometer::agent::notification
446   include ::ceilometer::agent::central
447   include ::ceilometer::expirer
448   include ::ceilometer::collector
449   include ::ceilometer::agent::auth
450   class { '::ceilometer::db' :
451     database_connection => $ceilometer_database_connection,
452   }
453
454   Cron <| title == 'ceilometer-expirer' |> { command => "sleep $((\$(od -A n -t d -N 3 /dev/urandom) % 86400)) && ${::ceilometer::params::expirer_command}" }
455
456   # Heat
457   include ::heat
458   include ::heat::api
459   include ::heat::api_cfn
460   include ::heat::api_cloudwatch
461   include ::heat::engine
462
463   # Horizon
464   if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
465     $_profile_support = 'cisco'
466   } else {
467     $_profile_support = 'None'
468   }
469   $neutron_options   = {'profile_support' => $_profile_support }
470
471   class { '::horizon':
472     cache_server_ip => hiera('memcache_node_ips', '127.0.0.1'),
473     neutron_options => $neutron_options,
474   }
475
476   $snmpd_user = hiera('snmpd_readonly_user_name')
477   snmp::snmpv3_user { $snmpd_user:
478     authtype => 'MD5',
479     authpass => hiera('snmpd_readonly_user_password'),
480   }
481   class { '::snmp':
482     agentaddress => ['udp:161','udp6:[::1]:161'],
483     snmpd_config => [ join(['rouser ', hiera('snmpd_readonly_user_name')]), 'proc  cron', 'includeAllDisks  10%', 'master agentx', 'trapsink localhost public', 'iquerySecName internalUser', 'rouser internalUser', 'defaultMonitors yes', 'linkUpDownNotifications yes' ],
484   }
485
486   hiera_include('controller_classes')
487
488 } #END STEP 3
489
490 if hiera('step') >= 4 {
491   include ::keystone::cron::token_flush
492 } #END STEP 4
493
494 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller', hiera('step')])
495 package_manifest{$package_manifest_name: ensure => present}