Merge "Remove invalid NTP configuration in templates"
[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
80   if $::osfamily == 'RedHat' {
81     $rabbit_provider = 'yum'
82   } else {
83     $rabbit_provider = undef
84   }
85
86   Class['rabbitmq'] -> Rabbitmq_vhost <| |>
87   Class['rabbitmq'] -> Rabbitmq_user <| |>
88   Class['rabbitmq'] -> Rabbitmq_user_permissions <| |>
89
90   # TODO Rabbit HA
91   class { 'rabbitmq':
92     package_provider  => $rabbit_provider,
93     config_cluster    => false,
94     node_ip_address   => hiera('controller_host'),
95   }
96
97   rabbitmq_vhost { '/':
98     provider => 'rabbitmqctl',
99   }
100   rabbitmq_user { ['nova','glance','neutron','cinder','ceilometer','heat']:
101     admin    => true,
102     password => hiera('rabbit_password'),
103     provider => 'rabbitmqctl',
104   }
105
106   rabbitmq_user_permissions {[
107     'nova@/',
108     'glance@/',
109     'neutron@/',
110     'cinder@/',
111     'ceilometer@/',
112     'heat@/',
113   ]:
114     configure_permission => '.*',
115     write_permission     => '.*',
116     read_permission      => '.*',
117     provider             => 'rabbitmqctl',
118   }
119
120 } #END STEP 1
121
122 if hiera('step') >= 2 {
123
124   include ::keystone
125
126   #TODO: need a cleanup-keystone-tokens.sh solution here
127   keystone_config {
128     'ec2/driver': value => 'keystone.contrib.ec2.backends.sql.Ec2';
129   }
130   file { [ '/etc/keystone/ssl', '/etc/keystone/ssl/certs', '/etc/keystone/ssl/private' ]:
131     ensure  => 'directory',
132     owner   => 'keystone',
133     group   => 'keystone',
134     require => Package['keystone'],
135   }
136   file { '/etc/keystone/ssl/certs/signing_cert.pem':
137     content => hiera('keystone_signing_certificate'),
138     owner   => 'keystone',
139     group   => 'keystone',
140     notify  => Service['keystone'],
141     require => File['/etc/keystone/ssl/certs'],
142   }
143   file { '/etc/keystone/ssl/private/signing_key.pem':
144     content => hiera('keystone_signing_key'),
145     owner   => 'keystone',
146     group   => 'keystone',
147     notify  => Service['keystone'],
148     require => File['/etc/keystone/ssl/private'],
149   }
150   file { '/etc/keystone/ssl/certs/ca.pem':
151     content => hiera('keystone_ca_certificate'),
152     owner   => 'keystone',
153     group   => 'keystone',
154     notify  => Service['keystone'],
155     require => File['/etc/keystone/ssl/certs'],
156   }
157
158   # TODO: swift backend, also notifications, scrubber, etc.
159   include ::glance::api
160   include ::glance::registry
161
162   class { 'nova':
163     rabbit_hosts           => [hiera('controller_virtual_ip')],
164     glance_api_servers     => join([hiera('glance_protocol'), '://', hiera('controller_virtual_ip'), ':', hiera('glance_port')]),
165   }
166
167   include ::nova::api
168   include ::nova::cert
169   include ::nova::conductor
170   include ::nova::consoleauth
171   include ::nova::vncproxy
172   include ::nova::scheduler
173
174   class {'neutron':
175     rabbit_hosts => [hiera('controller_virtual_ip')],
176   }
177
178   include ::neutron::server
179   include ::neutron::agents::dhcp
180   include ::neutron::agents::l3
181
182   class { 'neutron::plugins::ml2':
183     flat_networks        => split(hiera('neutron_flat_networks'), ','),
184     tenant_network_types => [hiera('neutron_tenant_network_type')],
185     type_drivers         => [hiera('neutron_tenant_network_type')],
186   }
187
188   class { 'neutron::agents::ml2::ovs':
189     bridge_mappings  => split(hiera('neutron_bridge_mappings'), ','),
190     tunnel_types     => split(hiera('neutron_tunnel_types'), ','),
191   }
192
193   class { 'neutron::agents::metadata':
194     auth_url => join(['http://', hiera('controller_virtual_ip'), ':35357/v2.0']),
195   }
196
197   class {'cinder':
198     rabbit_hosts => [hiera('controller_virtual_ip')],
199   }
200
201   include ::cinder::api
202   include ::cinder::scheduler
203   include ::cinder::volume
204   include ::cinder::volume::iscsi
205   class {'cinder::setup_test_volume':
206     size => join([hiera('cinder_lvm_loop_device_size'), 'M']),
207   }
208
209 } #END STEP 2