fb256806b56a7ddd392a51d8b2de64aa8e186d16
[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 'opencontrail'
177   # include opencontrail core plugins
178   # else use the default value of 'ml2'
179   if hiera('neutron::core_plugin') == 'neutron_plugin_contrail.plugins.opencontrail.contrail_plugin.NeutronPluginContrailCoreV2' {
180     include ::neutron::plugins::opencontrail
181   } else {
182
183     # If the value of core plugin is set to 'midonet',
184     # skip all the ML2 configuration
185     if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
186
187       class {'::neutron::plugins::midonet':
188         midonet_api_ip    => hiera('public_virtual_ip'),
189         keystone_tenant   => hiera('neutron::server::auth_tenant'),
190         keystone_password => hiera('neutron::server::password')
191       }
192     }
193
194     Service['neutron-server'] -> Service['neutron-metadata']
195
196   }
197
198   if $enable_ceph {
199     $ceph_pools = hiera('ceph_pools')
200     ceph::pool { $ceph_pools :
201       pg_num  => hiera('ceph::profile::params::osd_pool_default_pg_num'),
202       pgp_num => hiera('ceph::profile::params::osd_pool_default_pgp_num'),
203       size    => hiera('ceph::profile::params::osd_pool_default_size'),
204     }
205   }
206
207   # swift storage
208   if str2bool(hiera('enable_swift_storage', true)) {
209     class { '::swift::storage::all':
210       mount_check => str2bool(hiera('swift_mount_check')),
211     }
212     if(!defined(File['/srv/node'])) {
213       file { '/srv/node':
214         ensure  => directory,
215         owner   => 'swift',
216         group   => 'swift',
217         require => Package['openstack-swift'],
218       }
219     }
220     $swift_components = ['account', 'container', 'object']
221     swift::storage::filter::recon { $swift_components : }
222     swift::storage::filter::healthcheck { $swift_components : }
223   }
224
225   # Aodh
226   class { '::aodh' :
227     database_connection => hiera('aodh_mysql_conn_string'),
228   }
229   include ::aodh::db::sync
230   include ::aodh::auth
231   include ::aodh::api
232   include ::aodh::wsgi::apache
233   include ::aodh::evaluator
234   include ::aodh::notifier
235   include ::aodh::listener
236   include ::aodh::client
237
238   # Horizon
239   include ::apache::mod::remoteip
240   if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
241     $_profile_support = 'cisco'
242   } else {
243     $_profile_support = 'None'
244   }
245   $neutron_options   = {'profile_support' => $_profile_support }
246
247   $memcached_ipv6 = hiera('memcached_ipv6', false)
248   if $memcached_ipv6 {
249     $horizon_memcached_servers = hiera('memcache_node_ips_v6', '[::1]')
250   } else {
251     $horizon_memcached_servers = hiera('memcache_node_ips', '127.0.0.1')
252   }
253
254   class { '::horizon':
255     cache_server_ip => $horizon_memcached_servers,
256     neutron_options => $neutron_options,
257   }
258
259   # Gnocchi
260   $gnocchi_database_connection = hiera('gnocchi_mysql_conn_string')
261   class { '::gnocchi':
262     database_connection => $gnocchi_database_connection,
263   }
264   include ::gnocchi::api
265   include ::gnocchi::wsgi::apache
266   include ::gnocchi::client
267   include ::gnocchi::db::sync
268   include ::gnocchi::storage
269   include ::gnocchi::metricd
270   include ::gnocchi::statsd
271   $gnocchi_backend = downcase(hiera('gnocchi_backend', 'swift'))
272   case $gnocchi_backend {
273       'swift': { include ::gnocchi::storage::swift }
274       'file': { include ::gnocchi::storage::file }
275       'rbd': { include ::gnocchi::storage::ceph }
276       default: { fail('Unrecognized gnocchi_backend parameter.') }
277   }
278
279   $snmpd_user = hiera('snmpd_readonly_user_name')
280   snmp::snmpv3_user { $snmpd_user:
281     authtype => 'MD5',
282     authpass => hiera('snmpd_readonly_user_password'),
283   }
284   class { '::snmp':
285     agentaddress => ['udp:161','udp6:[::1]:161'],
286     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' ],
287   }
288
289   hiera_include('controller_classes')
290
291 } #END STEP 4
292
293 if hiera('step') >= 5 {
294   $nova_enable_db_purge = hiera('nova_enable_db_purge', true)
295
296   if $nova_enable_db_purge {
297     include ::nova::cron::archive_deleted_rows
298   }
299 } #END STEP 5
300
301 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller', hiera('step')])
302 package_manifest{$package_manifest_name: ensure => present}