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