Merge "Add output for host entries"
[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     class { '::neutron::plugins::ml2':
256       flat_networks        => split(hiera('neutron_flat_networks'), ','),
257       tenant_network_types => [hiera('neutron_tenant_network_type')],
258       mechanism_drivers    => [hiera('neutron_mechanism_drivers')],
259     }
260     class { '::neutron::agents::ml2::ovs':
261       bridge_mappings => split(hiera('neutron_bridge_mappings'), ','),
262       tunnel_types    => split(hiera('neutron_tunnel_types'), ','),
263     }
264     if 'cisco_n1kv' in hiera('neutron_mechanism_drivers') {
265       include ::neutron::plugins::ml2::cisco::nexus1000v
266
267       class { '::neutron::agents::n1kv_vem':
268         n1kv_source  => hiera('n1kv_vem_source', undef),
269         n1kv_version => hiera('n1kv_vem_version', undef),
270       }
271
272       class { '::n1k_vsm':
273         n1kv_source       => hiera('n1kv_vsm_source', undef),
274         n1kv_version      => hiera('n1kv_vsm_version', undef),
275         pacemaker_control => false,
276       }
277     }
278
279     if 'cisco_ucsm' in hiera('neutron_mechanism_drivers') {
280       include ::neutron::plugins::ml2::cisco::ucsm
281     }
282     if 'cisco_nexus' in hiera('neutron_mechanism_drivers') {
283       include ::neutron::plugins::ml2::cisco::nexus
284       include ::neutron::plugins::ml2::cisco::type_nexus_vxlan
285     }
286
287     if hiera('neutron_enable_bigswitch_ml2', false) {
288       include ::neutron::plugins::ml2::bigswitch::restproxy
289     }
290     neutron_l3_agent_config {
291       'DEFAULT/ovs_use_veth': value => hiera('neutron_ovs_use_veth', false);
292     }
293     neutron_dhcp_agent_config {
294       'DEFAULT/ovs_use_veth': value => hiera('neutron_ovs_use_veth', false);
295     }
296
297     Service['neutron-server'] -> Service['neutron-dhcp-service']
298     Service['neutron-server'] -> Service['neutron-l3']
299     Service['neutron-server'] -> Service['neutron-ovs-agent-service']
300     Service['neutron-server'] -> Service['neutron-metadata']
301   }
302
303   include ::cinder
304   include ::cinder::api
305   include ::cinder::glance
306   include ::cinder::scheduler
307   include ::cinder::volume
308   class { '::cinder::setup_test_volume':
309     size => join([hiera('cinder_lvm_loop_device_size'), 'M']),
310   }
311
312   $cinder_enable_iscsi = hiera('cinder_enable_iscsi_backend', true)
313   if $cinder_enable_iscsi {
314     $cinder_iscsi_backend = 'tripleo_iscsi'
315
316     cinder::backend::iscsi { $cinder_iscsi_backend :
317       iscsi_ip_address => hiera('cinder_iscsi_ip_address'),
318       iscsi_helper     => hiera('cinder_iscsi_helper'),
319     }
320   }
321
322   if $enable_ceph {
323
324     $ceph_pools = hiera('ceph_pools')
325     ceph::pool { $ceph_pools :
326       pg_num  => hiera('ceph::profile::params::osd_pool_default_pg_num'),
327       pgp_num => hiera('ceph::profile::params::osd_pool_default_pgp_num'),
328       size    => hiera('ceph::profile::params::osd_pool_default_size'),
329     }
330
331     $cinder_pool_requires = [Ceph::Pool[hiera('cinder_rbd_pool_name')]]
332
333   } else {
334     $cinder_pool_requires = []
335   }
336
337   if hiera('cinder_enable_rbd_backend', false) {
338     $cinder_rbd_backend = 'tripleo_ceph'
339
340     cinder::backend::rbd { $cinder_rbd_backend :
341       rbd_pool        => hiera('cinder_rbd_pool_name'),
342       rbd_user        => hiera('ceph_client_user_name'),
343       rbd_secret_uuid => hiera('ceph::profile::params::fsid'),
344       require         => $cinder_pool_requires,
345     }
346   }
347
348   if hiera('cinder_enable_netapp_backend', false) {
349     $cinder_netapp_backend = hiera('cinder::backend::netapp::title')
350
351     cinder_config {
352       "${cinder_netapp_backend}/host": value => 'hostgroup';
353     }
354
355     if hiera('cinder::backend::netapp::nfs_shares', undef) {
356       $cinder_netapp_nfs_shares = split(hiera('cinder::backend::netapp::nfs_shares', undef), ',')
357     }
358
359     cinder::backend::netapp { $cinder_netapp_backend :
360       netapp_login                 => hiera('cinder::backend::netapp::netapp_login', undef),
361       netapp_password              => hiera('cinder::backend::netapp::netapp_password', undef),
362       netapp_server_hostname       => hiera('cinder::backend::netapp::netapp_server_hostname', undef),
363       netapp_server_port           => hiera('cinder::backend::netapp::netapp_server_port', undef),
364       netapp_size_multiplier       => hiera('cinder::backend::netapp::netapp_size_multiplier', undef),
365       netapp_storage_family        => hiera('cinder::backend::netapp::netapp_storage_family', undef),
366       netapp_storage_protocol      => hiera('cinder::backend::netapp::netapp_storage_protocol', undef),
367       netapp_transport_type        => hiera('cinder::backend::netapp::netapp_transport_type', undef),
368       netapp_vfiler                => hiera('cinder::backend::netapp::netapp_vfiler', undef),
369       netapp_volume_list           => hiera('cinder::backend::netapp::netapp_volume_list', undef),
370       netapp_vserver               => hiera('cinder::backend::netapp::netapp_vserver', undef),
371       netapp_partner_backend_name  => hiera('cinder::backend::netapp::netapp_partner_backend_name', undef),
372       nfs_shares                   => $cinder_netapp_nfs_shares,
373       nfs_shares_config            => hiera('cinder::backend::netapp::nfs_shares_config', undef),
374       netapp_copyoffload_tool_path => hiera('cinder::backend::netapp::netapp_copyoffload_tool_path', undef),
375       netapp_controller_ips        => hiera('cinder::backend::netapp::netapp_controller_ips', undef),
376       netapp_sa_password           => hiera('cinder::backend::netapp::netapp_sa_password', undef),
377       netapp_storage_pools         => hiera('cinder::backend::netapp::netapp_storage_pools', undef),
378       netapp_eseries_host_type     => hiera('cinder::backend::netapp::netapp_eseries_host_type', undef),
379       netapp_webservice_path       => hiera('cinder::backend::netapp::netapp_webservice_path', undef),
380     }
381   }
382
383   if hiera('cinder_enable_nfs_backend', false) {
384     $cinder_nfs_backend = 'tripleo_nfs'
385
386     if str2bool($::selinux) {
387       selboolean { 'virt_use_nfs':
388         value      => on,
389         persistent => true,
390       } -> Package['nfs-utils']
391     }
392
393     package {'nfs-utils': } ->
394     cinder::backend::nfs { $cinder_nfs_backend :
395       nfs_servers       => hiera('cinder_nfs_servers'),
396       nfs_mount_options => hiera('cinder_nfs_mount_options',''),
397       nfs_shares_config => '/etc/cinder/shares-nfs.conf',
398     }
399   }
400
401   $cinder_enabled_backends = delete_undef_values([$cinder_iscsi_backend, $cinder_rbd_backend, $cinder_netapp_backend, $cinder_nfs_backend])
402   class { '::cinder::backends' :
403     enabled_backends => $cinder_enabled_backends,
404   }
405
406   # swift proxy
407   include ::memcached
408   include ::swift::proxy
409   include ::swift::proxy::proxy_logging
410   include ::swift::proxy::healthcheck
411   include ::swift::proxy::cache
412   include ::swift::proxy::keystone
413   include ::swift::proxy::authtoken
414   include ::swift::proxy::staticweb
415   include ::swift::proxy::ratelimit
416   include ::swift::proxy::catch_errors
417   include ::swift::proxy::tempurl
418   include ::swift::proxy::formpost
419
420   # swift storage
421   if str2bool(hiera('enable_swift_storage', true)) {
422     class { '::swift::storage::all':
423       mount_check => str2bool(hiera('swift_mount_check')),
424     }
425     if(!defined(File['/srv/node'])) {
426       file { '/srv/node':
427         ensure  => directory,
428         owner   => 'swift',
429         group   => 'swift',
430         require => Package['openstack-swift'],
431       }
432     }
433     $swift_components = ['account', 'container', 'object']
434     swift::storage::filter::recon { $swift_components : }
435     swift::storage::filter::healthcheck { $swift_components : }
436   }
437
438   # Ceilometer
439   $ceilometer_backend = downcase(hiera('ceilometer_backend'))
440   case $ceilometer_backend {
441     /mysql/ : {
442       $ceilometer_database_connection = hiera('ceilometer_mysql_conn_string')
443     }
444     default : {
445       $ceilometer_database_connection = $ceilometer_mongodb_conn_string
446     }
447   }
448   include ::ceilometer
449   include ::ceilometer::config
450   include ::ceilometer::api
451   include ::ceilometer::agent::notification
452   include ::ceilometer::agent::central
453   include ::ceilometer::expirer
454   include ::ceilometer::collector
455   include ::ceilometer::agent::auth
456   class { '::ceilometer::db' :
457     database_connection => $ceilometer_database_connection,
458   }
459
460   Cron <| title == 'ceilometer-expirer' |> { command => "sleep $((\$(od -A n -t d -N 3 /dev/urandom) % 86400)) && ${::ceilometer::params::expirer_command}" }
461
462   # Heat
463   include ::heat
464   include ::heat::api
465   include ::heat::api_cfn
466   include ::heat::api_cloudwatch
467   include ::heat::engine
468
469   # Horizon
470   if 'cisco_n1kv' in hiera('neutron_mechanism_drivers') {
471     $_profile_support = 'cisco'
472   } else {
473     $_profile_support = 'None'
474   }
475   $neutron_options   = {'profile_support' => $_profile_support }
476
477   class { '::horizon':
478     cache_server_ip => hiera('memcache_node_ips', '127.0.0.1'),
479     neutron_options => $neutron_options,
480   }
481
482   $snmpd_user = hiera('snmpd_readonly_user_name')
483   snmp::snmpv3_user { $snmpd_user:
484     authtype => 'MD5',
485     authpass => hiera('snmpd_readonly_user_password'),
486   }
487   class { '::snmp':
488     agentaddress => ['udp:161','udp6:[::1]:161'],
489     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' ],
490   }
491
492   hiera_include('controller_classes')
493
494 } #END STEP 3
495
496 if hiera('step') >= 4 {
497   include ::keystone::cron::token_flush
498 } #END STEP 4
499
500 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller', hiera('step')])
501 package_manifest{$package_manifest_name: ensure => present}