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