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