2b637b3720fd31a1301600157e9513cab34dd579
[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 if !str2bool(hiera('enable_package_install', 'false')) {
17   case $::osfamily {
18     'RedHat': {
19       Package { provider => 'norpm' } # provided by tripleo-puppet
20     }
21     default: {
22       warning('enable_package_install option not supported.')
23     }
24   }
25 }
26
27 if hiera('step') >= 1 {
28
29   $controller_node_ips = split(downcase(hiera('controller_node_ips')), ',')
30   class { '::tripleo::loadbalancer' :
31     controller_hosts => $controller_node_ips,
32   }
33
34 }
35
36 if hiera('step') >= 2 {
37
38   if count(hiera('ntp::servers')) > 0 {
39     include ::ntp
40   }
41
42   # TODO Galara
43   class { 'mysql::server':
44     override_options => {
45       'mysqld' => {
46         'bind-address' => hiera('controller_host')
47       }
48     }
49   }
50
51   # FIXME: this should only occur on the bootstrap host (ditto for db syncs)
52   # Create all the database schemas
53   # Example DSN format: mysql://user:password@host/dbname
54   $allowed_hosts = ['%',hiera('controller_host')]
55   $keystone_dsn = split(hiera('keystone::database_connection'), '[@:/?]')
56   class { 'keystone::db::mysql':
57     user          => $keystone_dsn[3],
58     password      => $keystone_dsn[4],
59     host          => $keystone_dsn[5],
60     dbname        => $keystone_dsn[6],
61     allowed_hosts => $allowed_hosts,
62   }
63   $glance_dsn = split(hiera('glance::api::database_connection'), '[@:/?]')
64   class { 'glance::db::mysql':
65     user          => $glance_dsn[3],
66     password      => $glance_dsn[4],
67     host          => $glance_dsn[5],
68     dbname        => $glance_dsn[6],
69     allowed_hosts => $allowed_hosts,
70   }
71   $nova_dsn = split(hiera('nova::database_connection'), '[@:/?]')
72   class { 'nova::db::mysql':
73     user          => $nova_dsn[3],
74     password      => $nova_dsn[4],
75     host          => $nova_dsn[5],
76     dbname        => $nova_dsn[6],
77     allowed_hosts => $allowed_hosts,
78   }
79   $neutron_dsn = split(hiera('neutron::server::database_connection'), '[@:/?]')
80   class { 'neutron::db::mysql':
81     user          => $neutron_dsn[3],
82     password      => $neutron_dsn[4],
83     host          => $neutron_dsn[5],
84     dbname        => $neutron_dsn[6],
85     allowed_hosts => $allowed_hosts,
86   }
87   $cinder_dsn = split(hiera('cinder::database_connection'), '[@:/?]')
88   class { 'cinder::db::mysql':
89     user          => $cinder_dsn[3],
90     password      => $cinder_dsn[4],
91     host          => $cinder_dsn[5],
92     dbname        => $cinder_dsn[6],
93     allowed_hosts => $allowed_hosts,
94   }
95   $heat_dsn = split(hiera('heat::database_connection'), '[@:/?]')
96   class { 'heat::db::mysql':
97     user          => $heat_dsn[3],
98     password      => $heat_dsn[4],
99     host          => $heat_dsn[5],
100     dbname        => $heat_dsn[6],
101     allowed_hosts => $allowed_hosts,
102   }
103   $ceilometer_dsn = split(hiera('ceilometer::db::database_connection'), '[@:/?]')
104   class { 'ceilometer::db::mysql':
105     user          => $ceilometer_dsn[3],
106     password      => $ceilometer_dsn[4],
107     host          => $ceilometer_dsn[5],
108     dbname        => $ceilometer_dsn[6],
109     allowed_hosts => $allowed_hosts,
110   }
111
112   $rabbit_nodes = split(downcase(hiera('rabbit_node_names', $::hostname)), ',')
113   if count($rabbit_nodes) > 1 {
114     $rabbit_cluster = true
115   }
116   else {
117     $rabbit_cluster = false
118   }
119   class { 'rabbitmq':
120     config_cluster   => $rabbit_cluster,
121     cluster_nodes    => $rabbit_nodes,
122     node_ip_address  => hiera('controller_host'),
123   }
124   if $rabbit_cluster {
125     rabbitmq_policy { 'ha-all@/':
126       pattern    => '^(?!amq\.).*',
127       definition => {
128         'ha-mode'      => 'all',
129         'ha-sync-mode' => 'automatic',
130       },
131     }
132   }
133   rabbitmq_vhost { '/':
134     provider => 'rabbitmqctl',
135   }
136
137   # pre-install swift here so we can build rings
138   include ::swift
139
140   $cinder_enable_rbd_backend = hiera('cinder_enable_rbd_backend', false)
141   $enable_ceph = $cinder_enable_rbd_backend
142
143   if $enable_ceph {
144     class { 'ceph::profile::params':
145       mon_initial_members => downcase(hiera('ceph_mon_initial_members'))
146     }
147     include ::ceph::profile::mon
148   }
149
150 } #END STEP 2
151
152 if hiera('step') >= 3 {
153
154   include ::keystone
155
156   #TODO: need a cleanup-keystone-tokens.sh solution here
157   keystone_config {
158     'ec2/driver': value => 'keystone.contrib.ec2.backends.sql.Ec2';
159   }
160   file { [ '/etc/keystone/ssl', '/etc/keystone/ssl/certs', '/etc/keystone/ssl/private' ]:
161     ensure  => 'directory',
162     owner   => 'keystone',
163     group   => 'keystone',
164     require => Package['keystone'],
165   }
166   file { '/etc/keystone/ssl/certs/signing_cert.pem':
167     content => hiera('keystone_signing_certificate'),
168     owner   => 'keystone',
169     group   => 'keystone',
170     notify  => Service['keystone'],
171     require => File['/etc/keystone/ssl/certs'],
172   }
173   file { '/etc/keystone/ssl/private/signing_key.pem':
174     content => hiera('keystone_signing_key'),
175     owner   => 'keystone',
176     group   => 'keystone',
177     notify  => Service['keystone'],
178     require => File['/etc/keystone/ssl/private'],
179   }
180   file { '/etc/keystone/ssl/certs/ca.pem':
181     content => hiera('keystone_ca_certificate'),
182     owner   => 'keystone',
183     group   => 'keystone',
184     notify  => Service['keystone'],
185     require => File['/etc/keystone/ssl/certs'],
186   }
187
188   # TODO: notifications, scrubber, etc.
189   include ::glance::api
190   include ::glance::registry
191   include ::glance::backend::swift
192
193   class { 'nova':
194     glance_api_servers     => join([hiera('glance_protocol'), '://', hiera('controller_virtual_ip'), ':', hiera('glance_port')]),
195   }
196
197   include ::nova::api
198   include ::nova::cert
199   include ::nova::conductor
200   include ::nova::consoleauth
201   include ::nova::network::neutron
202   include ::nova::vncproxy
203   include ::nova::scheduler
204
205   include ::neutron
206   include ::neutron::server
207   include ::neutron::agents::dhcp
208   include ::neutron::agents::l3
209
210   file { '/etc/neutron/dnsmasq-neutron.conf':
211     content => hiera('neutron_dnsmasq_options'),
212     owner   => 'neutron',
213     group   => 'neutron',
214     notify  => Service['neutron-dhcp-service'],
215     require => Package['neutron'],
216   }
217
218   class { 'neutron::plugins::ml2':
219     flat_networks        => split(hiera('neutron_flat_networks'), ','),
220     tenant_network_types => [hiera('neutron_tenant_network_type')],
221     type_drivers         => [hiera('neutron_tenant_network_type')],
222   }
223
224   class { 'neutron::agents::ml2::ovs':
225     bridge_mappings  => split(hiera('neutron_bridge_mappings'), ','),
226     tunnel_types     => split(hiera('neutron_tunnel_types'), ','),
227   }
228
229   class { 'neutron::agents::metadata':
230     auth_url => join(['http://', hiera('controller_virtual_ip'), ':35357/v2.0']),
231   }
232
233   Service['neutron-server'] -> Service['neutron-dhcp-service']
234   Service['neutron-server'] -> Service['neutron-l3']
235   Service['neutron-server'] -> Service['neutron-ovs-agent-service']
236   Service['neutron-server'] -> Service['neutron-metadata']
237
238   include ::cinder
239   include ::cinder::api
240   include ::cinder::glance
241   include ::cinder::scheduler
242   include ::cinder::volume
243   class {'cinder::setup_test_volume':
244     size => join([hiera('cinder_lvm_loop_device_size'), 'M']),
245   }
246
247   $cinder_enable_iscsi = hiera('cinder_enable_iscsi_backend', true)
248   if $cinder_enable_iscsi {
249     $cinder_iscsi_backend = 'tripleo_iscsi'
250
251     cinder::backend::iscsi { $cinder_iscsi_backend :
252       iscsi_ip_address => hiera('cinder_iscsi_ip_address'),
253       iscsi_helper     => hiera('cinder_iscsi_helper'),
254     }
255   }
256
257   if $enable_ceph {
258
259     Ceph_pool {
260       pg_num  => hiera('ceph::profile::params::osd_pool_default_pg_num'),
261       pgp_num => hiera('ceph::profile::params::osd_pool_default_pgp_num'),
262       size    => hiera('ceph::profile::params::osd_pool_default_size'),
263     }
264
265     $ceph_pools = hiera('ceph_pools')
266     ceph::pool { $ceph_pools : }
267   }
268
269   if $cinder_enable_rbd_backend {
270     $cinder_rbd_backend = 'tripleo_ceph'
271
272     cinder_config {
273       "${cinder_rbd_backend}/host": value => 'hostgroup';
274     }
275
276     cinder::backend::rbd { $cinder_rbd_backend :
277       rbd_pool        => 'volumes',
278       rbd_user        => 'openstack',
279       rbd_secret_uuid => hiera('ceph::profile::params::fsid'),
280       require         => Ceph::Pool['volumes'],
281     }
282   }
283
284   $cinder_enabled_backends = delete_undef_values([$cinder_iscsi_backend, $cinder_rbd_backend])
285   class { '::cinder::backends' :
286     enabled_backends => $cinder_enabled_backends,
287   }
288
289   # swift proxy
290   include ::memcached
291   include ::swift::proxy
292   include ::swift::proxy::proxy_logging
293   include ::swift::proxy::healthcheck
294   include ::swift::proxy::cache
295   include ::swift::proxy::keystone
296   include ::swift::proxy::authtoken
297   include ::swift::proxy::staticweb
298   include ::swift::proxy::ceilometer
299   include ::swift::proxy::ratelimit
300   include ::swift::proxy::catch_errors
301   include ::swift::proxy::tempurl
302   include ::swift::proxy::formpost
303
304   # swift storage
305   class {'swift::storage::all':
306     mount_check => str2bool(hiera('swift_mount_check'))
307   }
308   if(!defined(File['/srv/node'])) {
309     file { '/srv/node':
310       ensure  => directory,
311       owner   => 'swift',
312       group   => 'swift',
313       require => Package['openstack-swift'],
314     }
315   }
316   $swift_components = ['account', 'container', 'object']
317   swift::storage::filter::recon { $swift_components : }
318   swift::storage::filter::healthcheck { $swift_components : }
319
320   # Ceilometer
321   include ::ceilometer
322   include ::ceilometer::api
323   include ::ceilometer::db
324   include ::ceilometer::agent::notification
325   include ::ceilometer::agent::central
326   include ::ceilometer::alarm::notifier
327   include ::ceilometer::alarm::evaluator
328   include ::ceilometer::expirer
329   include ::ceilometer::collector
330   class { 'ceilometer::agent::auth':
331     auth_url => join(['http://', hiera('controller_virtual_ip'), ':5000/v2.0']),
332   }
333
334   Cron <| title == 'ceilometer-expirer' |> { command => "sleep $((\$(od -A n -t d -N 3 /dev/urandom) % 86400)) && ${::ceilometer::params::expirer_command}" }
335
336   # Heat
337   include ::heat
338   include ::heat::api
339   include ::heat::api_cfn
340   include ::heat::api_cloudwatch
341   include ::heat::engine
342
343   $snmpd_user = hiera('snmpd_readonly_user_name')
344   snmp::snmpv3_user { $snmpd_user:
345     authtype => 'MD5',
346     authpass => hiera('snmpd_readonly_user_password'),
347   }
348   class { 'snmp':
349     agentaddress => ['udp:161','udp6:[::1]:161'],
350     snmpd_config => [ join(['rouser ', hiera('snmpd_readonly_user_name')]), 'proc  cron', 'includeAllDisks  10%', 'master agentx', 'trapsink localhost public', 'iquerySecName internalUser', 'rouser internalUser', 'defaultMonitors yes', 'linkUpDownNotifications yes' ],
351   }
352
353 } #END STEP 3