Adding LICENSE file
[genesis.git] / fuel / build / f_osnaily / puppet / modules / osnailyfacter / examples / site.pp.orig
1 $fuel_settings = parseyaml($astute_settings_yaml)
2
3 $openstack_version = {
4   'keystone'   => 'installed',
5   'glance'     => 'installed',
6   'horizon'    => 'installed',
7   'nova'       => 'installed',
8   'novncproxy' => 'installed',
9   'cinder'     => 'installed',
10 }
11
12 tag("${::fuel_settings['deployment_id']}::${::fuel_settings['environment']}")
13
14 #Stages configuration
15 stage {'zero': } ->
16 stage {'first': } ->
17 stage {'openstack-custom-repo': } ->
18 stage {'netconfig': } ->
19 stage {'corosync_setup': } ->
20 stage {'openstack-firewall': } -> Stage['main']
21
22 class begin_deployment ()
23 {
24   $role = $::fuel_settings['role']
25   notify { "***** Beginning deployment of node ${::hostname} with role $role *****": }
26 }
27
28 class {'begin_deployment': stage => 'zero' }
29
30 stage {'glance-image':
31   require => Stage['main'],
32 }
33
34 if $::fuel_settings['nodes'] {
35   $nodes_hash = $::fuel_settings['nodes']
36   $dns_nameservers=$::fuel_settings['dns_nameservers']
37   $node = filter_nodes($nodes_hash,'name',$::hostname)
38   if empty($node) {
39     fail("Node $::hostname is not defined in the hash structure")
40   }
41
42   $default_gateway = $node[0]['default_gateway']
43
44   $base_syslog_hash     = $::fuel_settings['base_syslog']
45   $syslog_hash          = $::fuel_settings['syslog']
46
47   $disable_offload      = $::fuel_settings['disable_offload']
48   if $disable_offload {
49     L23network::L3::Ifconfig<||> {
50       ethtool =>     {
51         'K' => ['gso off',  'gro off'],
52       }
53     }
54   }
55
56   $use_neutron = $::fuel_settings['quantum']
57
58   if (!empty(filter_nodes($::fuel_settings['nodes'], 'role', 'ceph-osd')) or
59     $::fuel_settings['storage']['volumes_ceph'] or
60     $::fuel_settings['storage']['images_ceph'] or
61     $::fuel_settings['storage']['objects_ceph']
62   ) {
63     $use_ceph = true
64   } else {
65     $use_ceph = false
66   }
67
68
69   if $use_neutron {
70     prepare_network_config($::fuel_settings['network_scheme'])
71     #
72     $internal_int     = get_network_role_property('management', 'interface')
73     $internal_address = get_network_role_property('management', 'ipaddr')
74     $internal_netmask = get_network_role_property('management', 'netmask')
75     #
76     $public_int = get_network_role_property('ex', 'interface')
77     if $public_int {
78       $public_address = get_network_role_property('ex', 'ipaddr')
79       $public_netmask = get_network_role_property('ex', 'netmask')
80
81       # TODO(Xarses): remove this after completing merge of
82       # multiple-cluster-networks
83       L23network::L3::Ifconfig<| title == $public_int |> {
84         default_gateway => true
85       }
86     } else {
87       # TODO(Xarses): remove this after completing merge of
88       # multiple-cluster-networks
89       $fw_admin_int = get_network_role_property('fw-admin', 'interface')
90       L23network::L3::Ifconfig<| title == $fw_admin_int |> {
91         default_gateway => true
92       }
93     }
94     #
95     $storage_address = get_network_role_property('storage', 'ipaddr')
96     $storage_netmask = get_network_role_property('storage', 'netmask')
97   } else {
98     $internal_address = $node[0]['internal_address']
99     $internal_netmask = $node[0]['internal_netmask']
100     $public_address = $node[0]['public_address']
101     $public_netmask = $node[0]['public_netmask']
102     $storage_address = $node[0]['storage_address']
103     $storage_netmask = $node[0]['storage_netmask']
104     $public_br = $node[0]['public_br']
105     $internal_br = $node[0]['internal_br']
106     $public_int   = $::fuel_settings['public_interface']
107     $internal_int = $::fuel_settings['management_interface']
108
109     # TODO(Xarses): remove this after completing merge of
110     # multiple-cluster-networks
111     L23network::L3::Ifconfig<| title == $public_int |> {
112       default_gateway => true
113     }
114
115   }
116 }
117
118 if ($::fuel_settings['neutron_mellanox']) {
119   $mellanox_mode = $::fuel_settings['neutron_mellanox']['plugin']
120 } else {
121   $mellanox_mode = 'disabled'
122 }
123
124 # This parameter specifies the verbosity level of log messages
125 # in openstack components config.
126 # Debug would have set DEBUG level and ignore verbose settings, if any.
127 # Verbose would have set INFO level messages
128 # In case of non debug and non verbose - WARNING, default level would have set.
129 $verbose = true
130 $debug = $::fuel_settings['debug']
131
132 ### Storage Settings ###
133 # Determine if any ceph parts have been asked for.
134 # This will ensure that monitors are set up on controllers, even if no
135 #  ceph-osd roles during deployment
136
137
138 ### Syslog ###
139 #TODO(bogdando) move logging options to astute.yaml
140 # Enable error messages reporting to rsyslog. Rsyslog must be installed in this case.
141 $use_syslog = $::fuel_settings['use_syslog'] ? { default=>true }
142 # Syslog facilities for main openstack services
143 # should vary (reserved usage)
144 # local1 is reserved for openstack-dashboard
145 $syslog_log_facility_glance     = 'LOG_LOCAL2'
146 $syslog_log_facility_cinder     = 'LOG_LOCAL3'
147 $syslog_log_facility_neutron    = 'LOG_LOCAL4'
148 $syslog_log_facility_nova       = 'LOG_LOCAL6'
149 $syslog_log_facility_keystone   = 'LOG_LOCAL7'
150 # could be the same
151 # local0 is free for use
152 $syslog_log_facility_murano     = 'LOG_LOCAL0'
153 $syslog_log_facility_heat       = 'LOG_LOCAL0'
154 $syslog_log_facility_sahara     = 'LOG_LOCAL0'
155 $syslog_log_facility_ceilometer = 'LOG_LOCAL0'
156 $syslog_log_facility_ceph       = 'LOG_LOCAL0'
157
158 ### Monit ###
159 # Monit for compute nodes.
160 # If enabled, will install monit and configure its watchdogs to track
161 # nova-compute/api/network (and openvswitch service, if neutron enabled)
162 # at compute nodes.
163 # TODO(bogdando) set to true once monit package shipped with Fuel ISO
164 $use_monit = false
165
166 $nova_rate_limits = {
167   'POST' => 100000,
168   'POST_SERVERS' => 100000,
169   'PUT' => 1000, 'GET' => 100000,
170   'DELETE' => 100000
171 }
172 $cinder_rate_limits = {
173   'POST' => 100000,
174   'POST_SERVERS' => 100000,
175   'PUT' => 100000, 'GET' => 100000,
176   'DELETE' => 100000
177 }
178
179 ###
180 class advanced_node_netconfig {
181     $sdn = generate_network_config()
182     notify {"SDN: ${sdn}": }
183 }
184
185 case $::operatingsystem {
186   'redhat' : {
187     $queue_provider = 'qpid'
188     $custom_mysql_setup_class = 'pacemaker_mysql'
189   }
190   default: {
191     $queue_provider='rabbitmq'
192     $custom_mysql_setup_class='galera'
193   }
194 }
195
196 class os_common {
197   if ($::fuel_settings['neutron_mellanox']) {
198     if ($::mellanox_mode != 'disabled') {
199       class { 'mellanox_openstack::ofed_recompile' :
200         stage => 'zero',
201       }
202     }
203     if ($::fuel_settings['storage']['iser']) {
204       class { 'mellanox_openstack::iser_rename':
205         stage => 'zero',
206         storage_parent => $::fuel_settings['neutron_mellanox']['storage_parent'],
207         iser_interface_name => $::fuel_settings['neutron_mellanox']['iser_interface_name'],
208       }
209       Class['mellanox_openstack::ofed_recompile'] -> Class['mellanox_openstack::iser_rename']
210     }
211   }
212
213   class {"l23network::hosts_file": stage => 'netconfig', nodes => $nodes_hash }
214   class {'l23network': use_ovs=>$use_neutron, stage=> 'netconfig'}
215   if $use_neutron {
216       class {'advanced_node_netconfig': stage => 'netconfig' }
217   } else {
218       class {'osnailyfacter::network_setup': stage => 'netconfig'}
219   }
220
221   if ($::osfamily == 'RedHat') {
222     package {'irqbalance': ensure => present} -> service {'irqbalance': ensure => running }
223   }
224
225   class { 'openstack::firewall':
226     stage => 'openstack-firewall',
227     nova_vnc_ip_range => $::fuel_settings['management_network_range'],
228   }
229
230   $base_syslog_rserver  = {
231     'remote_type' => 'tcp',
232     'server' => $base_syslog_hash['syslog_server'],
233     'port' => $base_syslog_hash['syslog_port']
234   }
235
236 ### TCP connections keepalives and failover related parameters ###
237   # configure TCP keepalive for host OS.
238   # Send 3 probes each 8 seconds, if the connection was idle
239   # for a 30 seconds. Consider it dead, if there was no responces
240   # during the check time frame, i.e. 30+3*8=54 seconds overall.
241   # (note: overall check time frame should be lower then
242   # nova_report_interval).
243   class { 'openstack::keepalive' :
244     stage           => 'netconfig',
245     tcpka_time      => '30',
246     tcpka_probes    => '8',
247     tcpka_intvl     => '3',
248     tcp_retries2    => '5',
249   }
250
251   # setting kernel reserved ports
252   # defaults are 49000,35357,41055,58882
253   class { 'openstack::reserved_ports':
254     stage => 'netconfig',
255   }
256
257   # setting service down time and report interval
258   # to 60 and 180 for Nova respectively to allow kernel
259   # to kill dead connections
260   # (see zendesk #1158 as well)
261   $nova_report_interval = '60'
262   $nova_service_down_time  = '180'
263
264   $syslog_rserver = {
265     'remote_type' => $syslog_hash['syslog_transport'],
266     'server' => $syslog_hash['syslog_server'],
267     'port' => $syslog_hash['syslog_port'],
268   }
269   if $syslog_hash['syslog_server'] != "" and $syslog_hash['syslog_port'] != "" and $syslog_hash['syslog_transport'] != "" {
270     $rservers = [$base_syslog_rserver, $syslog_rserver]
271   } else {
272     $rservers = [$base_syslog_rserver]
273   }
274
275   if $use_syslog {
276     class { "::openstack::logging":
277       stage          => 'first',
278       role           => 'client',
279       show_timezone  => true,
280       # log both locally include auth, and remote
281       log_remote     => true,
282       log_local      => true,
283       log_auth_local => true,
284       # keep four weekly log rotations, force rotate if 300M size have exceeded
285       rotation       => 'weekly',
286       keep           => '4',
287       # should be > 30M
288       limitsize      => '300M',
289       # remote servers to send logs to
290       rservers       => $rservers,
291       # should be true, if client is running at virtual node
292       virtual        => str2bool($::is_virtual),
293       # Rabbit doesn't support syslog directly
294       rabbit_log_level => 'NOTICE',
295       debug            => $debug,
296     }
297   }
298
299   class { 'osnailyfacter::atop':
300     stage => 'first',
301   }
302
303   #case $role {
304     #    /controller/:          { $hostgroup = 'controller' }
305     #    /swift-proxy/: { $hostgroup = 'swift-proxy' }
306     #    /storage/:{ $hostgroup = 'swift-storage'  }
307     #    /compute/: { $hostgroup = 'compute'  }
308     #    /cinder/: { $hostgroup = 'cinder'  }
309     #    default: { $hostgroup = 'generic' }
310     #}
311
312     #  if $nagios != 'false' {
313     #  class {'nagios':
314     #    proj_name       => $proj_name,
315     #    services        => [
316     #      'host-alive','nova-novncproxy','keystone', 'nova-scheduler',
317     #      'nova-consoleauth', 'nova-cert', 'haproxy', 'nova-api', 'glance-api',
318     #      'glance-registry','horizon', 'rabbitmq', 'mysql',
319     #    ],
320     #    whitelist       => ['127.0.0.1', $nagios_master],
321     #    hostgroup       => $hostgroup ,
322     #  }
323     # }
324
325   # Workaround for fuel bug with firewall
326   firewall {'003 remote rabbitmq ':
327     sport   => [ 4369, 5672, 15672, 41055, 55672, 61613 ],
328     source  => $::fuel_settings['master_ip'],
329     proto   => 'tcp',
330     action  => 'accept',
331     require => Class['openstack::firewall'],
332   }
333
334   firewall {'004 remote puppet ':
335     sport   => [ 8140 ],
336     source  => $master_ip,
337     proto   => 'tcp',
338     action  => 'accept',
339     require => Class['openstack::firewall'],
340   }
341
342   class { 'puppet::pull' :
343     modules_source   => $::fuel_settings['puppet_modules_source'],
344     manifests_source => $::fuel_settings['puppet_manifests_source'],
345   }
346 } # OS_COMMON ENDS
347
348
349
350 node default {
351   case $::fuel_settings['deployment_mode'] {
352     "singlenode": {
353       include "osnailyfacter::cluster_simple"
354       class {'os_common':}
355       }
356     "multinode": {
357       include "osnailyfacter::cluster_simple"
358       class {'os_common':}
359       }
360     /^(ha|ha_compact)$/: {
361       include "osnailyfacter::cluster_ha"
362       class {'os_common':}
363       }
364     "rpmcache": { include osnailyfacter::rpmcache }
365   }
366 }