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