Merge "Template param for what command occ runs"
[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 include ::tripleo::packages
17 include ::tripleo::firewall
18
19 $enable_load_balancer = hiera('enable_load_balancer', true)
20
21 if hiera('step') >= 2 {
22
23   # MongoDB
24   if downcase(hiera('ceilometer_backend')) == 'mongodb' {
25     # NOTE(gfidente): We need to pass the list of IPv6 addresses *with* port and
26     # without the brackets as 'members' argument for the 'mongodb_replset'
27     # resource.
28     if str2bool(hiera('mongodb::server::ipv6', false)) {
29       $mongo_node_ips_with_port_prefixed = prefix(hiera('mongo_node_ips'), '[')
30       $mongo_node_ips_with_port = suffix($mongo_node_ips_with_port_prefixed, ']:27017')
31       $mongo_node_ips_with_port_nobr = suffix(hiera('mongo_node_ips'), ':27017')
32     } else {
33       $mongo_node_ips_with_port = suffix(hiera('mongo_node_ips'), ':27017')
34       $mongo_node_ips_with_port_nobr = suffix(hiera('mongo_node_ips'), ':27017')
35     }
36     $mongo_node_string = join($mongo_node_ips_with_port, ',')
37
38     $mongodb_replset = hiera('mongodb::server::replset')
39     $ceilometer_mongodb_conn_string = "mongodb://${mongo_node_string}/ceilometer?replicaSet=${mongodb_replset}"
40   }
41
42   if str2bool(hiera('enable_galera', true)) {
43     $mysql_config_file = '/etc/my.cnf.d/galera.cnf'
44   } else {
45     $mysql_config_file = '/etc/my.cnf.d/server.cnf'
46   }
47   # TODO Galara
48   # FIXME: due to https://bugzilla.redhat.com/show_bug.cgi?id=1298671 we
49   # set bind-address to a hostname instead of an ip address; to move Mysql
50   # from internal_api on another network we'll have to customize both
51   # MysqlNetwork and ControllerHostnameResolveNetwork in ServiceNetMap
52   class { '::mysql::server':
53     config_file             => $mysql_config_file,
54     override_options        => {
55       'mysqld' => {
56         'bind-address'     => $::hostname,
57         'max_connections'  => hiera('mysql_max_connections'),
58         'open_files_limit' => '-1',
59       },
60     },
61     remove_default_accounts => true,
62   }
63
64   # FIXME: this should only occur on the bootstrap host (ditto for db syncs)
65   # Create all the database schemas
66   if downcase(hiera('gnocchi_indexer_backend')) == 'mysql' {
67     include ::gnocchi::db::mysql
68   }
69   if downcase(hiera('ceilometer_backend')) == 'mysql' {
70     include ::ceilometer::db::mysql
71   }
72   include ::aodh::db::mysql
73
74 } #END STEP 2
75
76 if hiera('step') >= 4 {
77
78   $nova_ipv6 = hiera('nova::use_ipv6', false)
79   if $nova_ipv6 {
80     $memcached_servers = suffix(hiera('memcache_node_ips_v6'), ':11211')
81   } else {
82     $memcached_servers = suffix(hiera('memcache_node_ips'), ':11211')
83   }
84
85   class { '::nova' :
86     memcached_servers => $memcached_servers
87   }
88   include ::nova::config
89
90   # Ceilometer
91   $ceilometer_backend = downcase(hiera('ceilometer_backend'))
92   case $ceilometer_backend {
93     /mysql/ : {
94       $ceilometer_database_connection = hiera('ceilometer_mysql_conn_string')
95     }
96     default : {
97       $ceilometer_database_connection = $ceilometer_mongodb_conn_string
98     }
99   }
100   include ::ceilometer
101   include ::ceilometer::config
102   include ::ceilometer::api
103   include ::ceilometer::agent::notification
104   include ::ceilometer::agent::central
105   include ::ceilometer::expirer
106   include ::ceilometer::collector
107   include ::ceilometer::agent::auth
108   include ::ceilometer::dispatcher::gnocchi
109   class { '::ceilometer::db' :
110     database_connection => $ceilometer_database_connection,
111   }
112
113   Cron <| title == 'ceilometer-expirer' |> { command => "sleep $((\$(od -A n -t d -N 3 /dev/urandom) % 86400)) && ${::ceilometer::params::expirer_command}" }
114
115   # Aodh
116   class { '::aodh' :
117     database_connection => hiera('aodh_mysql_conn_string'),
118   }
119   include ::aodh::db::sync
120   include ::aodh::auth
121   include ::aodh::api
122   include ::aodh::wsgi::apache
123   include ::aodh::evaluator
124   include ::aodh::notifier
125   include ::aodh::listener
126   include ::aodh::client
127
128   # Horizon
129   include ::apache::mod::remoteip
130   if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
131     $_profile_support = 'cisco'
132   } else {
133     $_profile_support = 'None'
134   }
135   $neutron_options   = merge({'profile_support' => $_profile_support },hiera('horizon::neutron_options',undef))
136
137   $memcached_ipv6 = hiera('memcached_ipv6', false)
138   if $memcached_ipv6 {
139     $horizon_memcached_servers = hiera('memcache_node_ips_v6', '[::1]')
140   } else {
141     $horizon_memcached_servers = hiera('memcache_node_ips', '127.0.0.1')
142   }
143
144   class { '::horizon':
145     cache_server_ip => $horizon_memcached_servers,
146     neutron_options => $neutron_options,
147   }
148
149   # Gnocchi
150   $gnocchi_database_connection = hiera('gnocchi_mysql_conn_string')
151   class { '::gnocchi':
152     database_connection => $gnocchi_database_connection,
153   }
154   include ::gnocchi::api
155   include ::gnocchi::wsgi::apache
156   include ::gnocchi::client
157   include ::gnocchi::db::sync
158   include ::gnocchi::storage
159   include ::gnocchi::metricd
160   include ::gnocchi::statsd
161   $gnocchi_backend = downcase(hiera('gnocchi_backend', 'swift'))
162   case $gnocchi_backend {
163       'swift': { include ::gnocchi::storage::swift }
164       'file': { include ::gnocchi::storage::file }
165       'rbd': { include ::gnocchi::storage::ceph }
166       default: { fail('Unrecognized gnocchi_backend parameter.') }
167   }
168
169   hiera_include('controller_classes')
170
171 } #END STEP 4
172
173 if hiera('step') >= 5 {
174   $nova_enable_db_purge = hiera('nova_enable_db_purge', true)
175
176   if $nova_enable_db_purge {
177     include ::nova::cron::archive_deleted_rows
178   }
179 } #END STEP 5
180
181 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_controller', hiera('step')])
182 package_manifest{$package_manifest_name: ensure => present}