Puppet: Ceilometer controller support
[apex-tripleo-heat-templates.git] / puppet / 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 hiera('step') >= 1 {
17
18   # TODO Galara
19   class { 'mysql::server':
20     override_options => {
21       'mysqld' => {
22         'bind-address' => hiera('controller_host')
23       }
24     }
25   }
26
27   # FIXME: this should only occur on the bootstrap host (ditto for db syncs)
28   # Create all the database schemas
29   # Example DSN format: mysql://user:password@host/dbname
30   $allowed_hosts = ['%',hiera('controller_host')]
31   $keystone_dsn = split(hiera('keystone::database_connection'), '[@:/?]')
32   class { 'keystone::db::mysql':
33     user          => $keystone_dsn[3],
34     password      => $keystone_dsn[4],
35     host          => $keystone_dsn[5],
36     dbname        => $keystone_dsn[6],
37     allowed_hosts => $allowed_hosts,
38   }
39   $glance_dsn = split(hiera('glance::api::database_connection'), '[@:/?]')
40   class { 'glance::db::mysql':
41     user          => $glance_dsn[3],
42     password      => $glance_dsn[4],
43     host          => $glance_dsn[5],
44     dbname        => $glance_dsn[6],
45     allowed_hosts => $allowed_hosts,
46   }
47   $nova_dsn = split(hiera('nova::database_connection'), '[@:/?]')
48   class { 'nova::db::mysql':
49     user          => $nova_dsn[3],
50     password      => $nova_dsn[4],
51     host          => $nova_dsn[5],
52     dbname        => $nova_dsn[6],
53     allowed_hosts => $allowed_hosts,
54   }
55   $neutron_dsn = split(hiera('neutron::server::database_connection'), '[@:/?]')
56   class { 'neutron::db::mysql':
57     user          => $neutron_dsn[3],
58     password      => $neutron_dsn[4],
59     host          => $neutron_dsn[5],
60     dbname        => $neutron_dsn[6],
61     allowed_hosts => $allowed_hosts,
62   }
63   $cinder_dsn = split(hiera('cinder::database_connection'), '[@:/?]')
64   class { 'cinder::db::mysql':
65     user          => $cinder_dsn[3],
66     password      => $cinder_dsn[4],
67     host          => $cinder_dsn[5],
68     dbname        => $cinder_dsn[6],
69     allowed_hosts => $allowed_hosts,
70   }
71   $heat_dsn = split(hiera('heat_dsn'), '[@:/?]')
72   class { 'heat::db::mysql':
73     user          => $heat_dsn[3],
74     password      => $heat_dsn[4],
75     host          => $heat_dsn[5],
76     dbname        => $heat_dsn[6],
77     allowed_hosts => $allowed_hosts,
78   }
79   $ceilometer_dsn = split(hiera('ceilometer::db::database_connection'), '[@:/?]')
80   class { 'ceilometer::db::mysql':
81     user          => $ceilometer_dsn[3],
82     password      => $ceilometer_dsn[4],
83     host          => $ceilometer_dsn[5],
84     dbname        => $ceilometer_dsn[6],
85     allowed_hosts => $allowed_hosts,
86   }
87
88   if $::osfamily == 'RedHat' {
89     $rabbit_provider = 'yum'
90   } else {
91     $rabbit_provider = undef
92   }
93
94   Class['rabbitmq'] -> Rabbitmq_vhost <| |>
95   Class['rabbitmq'] -> Rabbitmq_user <| |>
96   Class['rabbitmq'] -> Rabbitmq_user_permissions <| |>
97
98   # TODO Rabbit HA
99   class { 'rabbitmq':
100     package_provider  => $rabbit_provider,
101     config_cluster    => false,
102     node_ip_address   => hiera('controller_host'),
103   }
104
105   rabbitmq_vhost { '/':
106     provider => 'rabbitmqctl',
107   }
108   rabbitmq_user { ['nova','glance','neutron','cinder','ceilometer','heat']:
109     admin    => true,
110     password => hiera('rabbit_password'),
111     provider => 'rabbitmqctl',
112   }
113
114   rabbitmq_user_permissions {[
115     'nova@/',
116     'glance@/',
117     'neutron@/',
118     'cinder@/',
119     'ceilometer@/',
120     'heat@/',
121   ]:
122     configure_permission => '.*',
123     write_permission     => '.*',
124     read_permission      => '.*',
125     provider             => 'rabbitmqctl',
126   }
127
128   # pre-install swift here so we can build rings
129   include ::swift
130
131 } #END STEP 1
132
133 if hiera('step') >= 2 {
134
135   include ::keystone
136
137   #TODO: need a cleanup-keystone-tokens.sh solution here
138   keystone_config {
139     'ec2/driver': value => 'keystone.contrib.ec2.backends.sql.Ec2';
140   }
141   file { [ '/etc/keystone/ssl', '/etc/keystone/ssl/certs', '/etc/keystone/ssl/private' ]:
142     ensure  => 'directory',
143     owner   => 'keystone',
144     group   => 'keystone',
145     require => Package['keystone'],
146   }
147   file { '/etc/keystone/ssl/certs/signing_cert.pem':
148     content => hiera('keystone_signing_certificate'),
149     owner   => 'keystone',
150     group   => 'keystone',
151     notify  => Service['keystone'],
152     require => File['/etc/keystone/ssl/certs'],
153   }
154   file { '/etc/keystone/ssl/private/signing_key.pem':
155     content => hiera('keystone_signing_key'),
156     owner   => 'keystone',
157     group   => 'keystone',
158     notify  => Service['keystone'],
159     require => File['/etc/keystone/ssl/private'],
160   }
161   file { '/etc/keystone/ssl/certs/ca.pem':
162     content => hiera('keystone_ca_certificate'),
163     owner   => 'keystone',
164     group   => 'keystone',
165     notify  => Service['keystone'],
166     require => File['/etc/keystone/ssl/certs'],
167   }
168
169   # TODO: notifications, scrubber, etc.
170   include ::glance::api
171   include ::glance::registry
172   class { 'glance::backend::swift':
173     swift_store_auth_address => join(['http://', hiera('controller_virtual_ip'), ':5000/v2.0']),
174   }
175
176   class { 'nova':
177     rabbit_hosts           => [hiera('controller_virtual_ip')],
178     glance_api_servers     => join([hiera('glance_protocol'), '://', hiera('controller_virtual_ip'), ':', hiera('glance_port')]),
179   }
180
181   include ::nova::api
182   include ::nova::cert
183   include ::nova::conductor
184   include ::nova::consoleauth
185   include ::nova::vncproxy
186   include ::nova::scheduler
187
188   class {'neutron':
189     rabbit_hosts => [hiera('controller_virtual_ip')],
190   }
191
192   include ::neutron::server
193   include ::neutron::agents::dhcp
194   include ::neutron::agents::l3
195
196   class { 'neutron::plugins::ml2':
197     flat_networks        => split(hiera('neutron_flat_networks'), ','),
198     tenant_network_types => [hiera('neutron_tenant_network_type')],
199     type_drivers         => [hiera('neutron_tenant_network_type')],
200   }
201
202   class { 'neutron::agents::ml2::ovs':
203     bridge_mappings  => split(hiera('neutron_bridge_mappings'), ','),
204     tunnel_types     => split(hiera('neutron_tunnel_types'), ','),
205   }
206
207   class { 'neutron::agents::metadata':
208     auth_url => join(['http://', hiera('controller_virtual_ip'), ':35357/v2.0']),
209   }
210
211   class {'cinder':
212     rabbit_hosts => [hiera('controller_virtual_ip')],
213   }
214
215   include ::cinder::api
216   include ::cinder::scheduler
217   include ::cinder::volume
218   include ::cinder::volume::iscsi
219   class {'cinder::setup_test_volume':
220     size => join([hiera('cinder_lvm_loop_device_size'), 'M']),
221   }
222
223   # swift proxy
224   include ::memcached
225   include ::swift::proxy
226   include ::swift::proxy::proxy_logging
227   include ::swift::proxy::healthcheck
228   include ::swift::proxy::cache
229   include ::swift::proxy::keystone
230   include ::swift::proxy::authtoken
231   include ::swift::proxy::staticweb
232   include ::swift::proxy::ceilometer
233   include ::swift::proxy::ratelimit
234   include ::swift::proxy::catch_errors
235   include ::swift::proxy::tempurl
236   include ::swift::proxy::formpost
237
238   # swift storage
239   class {'swift::storage::all':
240     mount_check => str2bool(hiera('swift_mount_check'))
241   }
242   if(!defined(File['/srv/node'])) {
243     file { '/srv/node':
244       ensure  => directory,
245       owner   => 'swift',
246       group   => 'swift',
247       require => Package['openstack-swift'],
248     }
249   }
250   $swift_components = ['account', 'container', 'object']
251   swift::storage::filter::recon { $swift_components : }
252   swift::storage::filter::healthcheck { $swift_components : }
253
254   # Ceilometer
255   include ::ceilometer
256   include ::ceilometer::api
257   include ::ceilometer::db
258   include ::ceilometer::agent::notification
259   include ::ceilometer::agent::central
260   include ::ceilometer::alarm::notifier
261   include ::ceilometer::alarm::evaluator
262   include ::ceilometer::expirer
263   include ::ceilometer::collector
264   class { 'ceilometer::agent::auth':
265     auth_url => join(['http://', hiera('controller_virtual_ip'), ':5000/v2.0']),
266   }
267
268   Cron <| title == 'ceilometer-expirer' |> { command => "sleep $((\$(od -A n -t d -N 3 /dev/urandom) % 86400)) && ${::ceilometer::params::expirer_command}" }
269
270 } #END STEP 2