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