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