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