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