Allow neutron_options customization for dashboard
[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   include ::timezone
32
33   if str2bool(hiera('enable_galera', true)) {
34     $mysql_config_file = '/etc/my.cnf.d/galera.cnf'
35   } else {
36     $mysql_config_file = '/etc/my.cnf.d/server.cnf'
37   }
38   # TODO Galara
39   # FIXME: due to https://bugzilla.redhat.com/show_bug.cgi?id=1298671 we
40   # set bind-address to a hostname instead of an ip address; to move Mysql
41   # from internal_api on another network we'll have to customize both
42   # MysqlNetwork and ControllerHostnameResolveNetwork in ServiceNetMap
43   class { '::mysql::server':
44     config_file             => $mysql_config_file,
45     override_options        => {
46       'mysqld' => {
47         'bind-address'     => $::hostname,
48         'max_connections'  => hiera('mysql_max_connections'),
49         'open_files_limit' => '-1',
50       },
51     },
52     remove_default_accounts => true,
53   }
54
55   # FIXME: this should only occur on the bootstrap host (ditto for db syncs)
56   # Create all the database schemas
57   if downcase(hiera('gnocchi_indexer_backend')) == 'mysql' {
58     include ::gnocchi::db::mysql
59   }
60   include ::aodh::db::mysql
61
62   $enable_ceph = hiera('ceph_storage_count', 0) > 0 or hiera('enable_ceph_storage', false)
63
64   if $enable_ceph {
65     $mon_initial_members = downcase(hiera('ceph_mon_initial_members'))
66     if str2bool(hiera('ceph_ipv6', false)) {
67       $mon_host = hiera('ceph_mon_host_v6')
68     } else {
69       $mon_host = hiera('ceph_mon_host')
70     }
71     class { '::ceph::profile::params':
72       mon_initial_members => $mon_initial_members,
73       mon_host            => $mon_host,
74     }
75     include ::ceph::conf
76     include ::ceph::profile::mon
77   }
78
79   if str2bool(hiera('enable_ceph_storage', false)) {
80     if str2bool(hiera('ceph_osd_selinux_permissive', true)) {
81       exec { 'set selinux to permissive on boot':
82         command => "sed -ie 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config",
83         onlyif  => "test -f /etc/selinux/config && ! grep '^SELINUX=permissive' /etc/selinux/config",
84         path    => ['/usr/bin', '/usr/sbin'],
85       }
86
87       exec { 'set selinux to permissive':
88         command => 'setenforce 0',
89         onlyif  => "which setenforce && getenforce | grep -i 'enforcing'",
90         path    => ['/usr/bin', '/usr/sbin'],
91       } -> Class['ceph::profile::osd']
92     }
93
94     include ::ceph::conf
95     include ::ceph::profile::osd
96   }
97
98   if str2bool(hiera('enable_external_ceph', false)) {
99     if str2bool(hiera('ceph_ipv6', false)) {
100       $mon_host = hiera('ceph_mon_host_v6')
101     } else {
102       $mon_host = hiera('ceph_mon_host')
103     }
104     class { '::ceph::profile::params':
105       mon_host            => $mon_host,
106     }
107     include ::ceph::conf
108     include ::ceph::profile::client
109   }
110
111 } #END STEP 2
112
113 if hiera('step') >= 4 {
114
115   $nova_ipv6 = hiera('nova::use_ipv6', false)
116   if $nova_ipv6 {
117     $memcached_servers = suffix(hiera('memcache_node_ips_v6'), ':11211')
118   } else {
119     $memcached_servers = suffix(hiera('memcache_node_ips'), ':11211')
120   }
121
122   class { '::nova' :
123     memcached_servers => $memcached_servers
124   }
125   include ::nova::config
126
127   if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
128
129     # TODO(devvesa) provide non-controller ips for these services
130     $zookeeper_node_ips = hiera('neutron_api_node_ips')
131     $cassandra_node_ips = hiera('neutron_api_node_ips')
132
133     # Run zookeeper in the controller if configured
134     if hiera('enable_zookeeper_on_controller') {
135       class {'::tripleo::cluster::zookeeper':
136         zookeeper_server_ips => $zookeeper_node_ips,
137         # TODO: create a 'bind' hiera key for zookeeper
138         zookeeper_client_ip  => hiera('neutron::bind_host'),
139         zookeeper_hostnames  => hiera('controller_node_names')
140       }
141     }
142
143     # Run cassandra in the controller if configured
144     if hiera('enable_cassandra_on_controller') {
145       class {'::tripleo::cluster::cassandra':
146         cassandra_servers => $cassandra_node_ips,
147         # TODO: create a 'bind' hiera key for cassandra
148         cassandra_ip      => hiera('neutron::bind_host'),
149       }
150     }
151
152     class {'::tripleo::network::midonet::agent':
153       zookeeper_servers => $zookeeper_node_ips,
154       cassandra_seeds   => $cassandra_node_ips
155     }
156
157     class {'::tripleo::network::midonet::api':
158       zookeeper_servers    => $zookeeper_node_ips,
159       vip                  => hiera('public_virtual_ip'),
160       keystone_ip          => hiera('public_virtual_ip'),
161       keystone_admin_token => hiera('keystone::admin_token'),
162       # TODO: create a 'bind' hiera key for api
163       bind_address         => hiera('neutron::bind_host'),
164       admin_password       => hiera('admin_password')
165     }
166
167     # TODO: find a way to get an empty list from hiera
168     # TODO: when doing the composable midonet plugin, don't forget to
169     # set service_plugins to an empty array in Hiera.
170     class {'::neutron':
171       service_plugins => []
172     }
173
174   }
175
176   # If the value of core plugin is set to 'midonet',
177   # skip all the ML2 configuration
178   if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
179
180     class {'::neutron::plugins::midonet':
181       midonet_api_ip    => hiera('public_virtual_ip'),
182       keystone_tenant   => hiera('neutron::server::auth_tenant'),
183       keystone_password => hiera('neutron::server::password')
184     }
185   }
186
187   if $enable_ceph {
188     $ceph_pools = hiera('ceph_pools')
189     ceph::pool { $ceph_pools :
190       pg_num  => hiera('ceph::profile::params::osd_pool_default_pg_num'),
191       pgp_num => hiera('ceph::profile::params::osd_pool_default_pgp_num'),
192       size    => hiera('ceph::profile::params::osd_pool_default_size'),
193     }
194   }
195
196   # swift storage
197   if str2bool(hiera('enable_swift_storage', true)) {
198     class { '::swift::storage::all':
199       mount_check => str2bool(hiera('swift_mount_check')),
200     }
201     if(!defined(File['/srv/node'])) {
202       file { '/srv/node':
203         ensure  => directory,
204         owner   => 'swift',
205         group   => 'swift',
206         require => Package['openstack-swift'],
207       }
208     }
209     $swift_components = ['account', 'container', 'object']
210     swift::storage::filter::recon { $swift_components : }
211     swift::storage::filter::healthcheck { $swift_components : }
212   }
213
214   # Aodh
215   class { '::aodh' :
216     database_connection => hiera('aodh_mysql_conn_string'),
217   }
218   include ::aodh::db::sync
219   include ::aodh::auth
220   include ::aodh::api
221   include ::aodh::wsgi::apache
222   include ::aodh::evaluator
223   include ::aodh::notifier
224   include ::aodh::listener
225   include ::aodh::client
226
227   # Horizon
228   include ::apache::mod::remoteip
229   if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
230     $_profile_support = 'cisco'
231   } else {
232     $_profile_support = 'None'
233   }
234   $neutron_options   = merge({'profile_support' => $_profile_support },hiera('horizon::neutron_options',undef))
235
236   $memcached_ipv6 = hiera('memcached_ipv6', false)
237   if $memcached_ipv6 {
238     $horizon_memcached_servers = hiera('memcache_node_ips_v6', '[::1]')
239   } else {
240     $horizon_memcached_servers = hiera('memcache_node_ips', '127.0.0.1')
241   }
242
243   class { '::horizon':
244     cache_server_ip => $horizon_memcached_servers,
245     neutron_options => $neutron_options,
246   }
247
248   # Gnocchi
249   $gnocchi_database_connection = hiera('gnocchi_mysql_conn_string')
250   class { '::gnocchi':
251     database_connection => $gnocchi_database_connection,
252   }
253   include ::gnocchi::api
254   include ::gnocchi::wsgi::apache
255   include ::gnocchi::client
256   include ::gnocchi::db::sync
257   include ::gnocchi::storage
258   include ::gnocchi::metricd
259   include ::gnocchi::statsd
260   $gnocchi_backend = downcase(hiera('gnocchi_backend', 'swift'))
261   case $gnocchi_backend {
262       'swift': { include ::gnocchi::storage::swift }
263       'file': { include ::gnocchi::storage::file }
264       'rbd': { include ::gnocchi::storage::ceph }
265       default: { fail('Unrecognized gnocchi_backend parameter.') }
266   }
267
268   $snmpd_user = hiera('snmpd_readonly_user_name')
269   snmp::snmpv3_user { $snmpd_user:
270     authtype => 'MD5',
271     authpass => hiera('snmpd_readonly_user_password'),
272   }
273   class { '::snmp':
274     agentaddress => ['udp:161','udp6:[::1]:161'],
275     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' ],
276   }
277
278   hiera_include('controller_classes')
279
280 } #END STEP 4
281
282 if hiera('step') >= 5 {
283   $nova_enable_db_purge = hiera('nova_enable_db_purge', true)
284
285   if $nova_enable_db_purge {
286     include ::nova::cron::archive_deleted_rows
287   }
288 } #END STEP 5
289
290 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller', hiera('step')])
291 package_manifest{$package_manifest_name: ensure => present}