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