Add coala support and fix/lint files
[integration/packaging/puppet-opendaylight.git] / manifests / config.pp
1 # == Class opendaylight::config
2 #
3 # This class handles ODL config changes.
4 # It's called from the opendaylight class.
5 #
6 class opendaylight::config {
7   # Configuration of Karaf features to install
8   file { 'org.apache.karaf.features.cfg':
9     ensure => file,
10     path   => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
11     # Set user:group owners
12     owner  => 'odl',
13     group  => 'odl',
14   }
15   $features_csv = join($opendaylight::features, ',')
16   file_line { 'featuresBoot':
17     path  => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
18     line  => "featuresBoot=${features_csv}",
19     match => '^featuresBoot=.*$',
20   }
21
22   # Configuration of ODL NB REST port to listen on
23   file { 'jetty.xml':
24     ensure  => file,
25     path    => '/opt/opendaylight/etc/jetty.xml',
26     # Set user:group owners
27     owner   => 'odl',
28     group   => 'odl',
29     # Use a template to populate the content
30     content => template('opendaylight/jetty.xml.erb'),
31   }
32
33   # Enable or disable ODL OVSDB ML2 L3 forwarding
34   file { 'custom.properties':
35     ensure  => file,
36     path    => '/opt/opendaylight/etc/custom.properties',
37     # Set user:group owners
38     owner   => 'odl',
39     group   => 'odl',
40     # Use a template to populate the content
41     content => template('opendaylight/custom.properties.erb'),
42   }
43
44   # Set any custom log levels
45   file { 'org.ops4j.pax.logging.cfg':
46     ensure  => file,
47     path    => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
48     # Set user:group owners
49     owner   => 'odl',
50     group   => 'odl',
51     # Use a template to populate the content
52     content => template('opendaylight/org.ops4j.pax.logging.cfg.erb'),
53   }
54
55   # Configure ODL HA if enabled
56   $ha_node_count = count($::opendaylight::ha_node_ips)
57   if $::opendaylight::enable_ha {
58     if $ha_node_count >= 2 {
59       # Configuration Jolokia XML for HA
60       file { 'opendaylight/jolokia.xml':
61         ensure => file,
62         path   => '/opt/opendaylight/deploy/jolokia.xml',
63         # Set user:group owners
64         owner  => 'odl',
65         group  => 'odl',
66         source => 'puppet:///modules/opendaylight/jolokia.xml',
67       }
68
69       # Configure ODL OSVDB Clustering
70       $ha_node_ip_str = join($::opendaylight::ha_node_ips, ' ')
71       exec { 'Configure ODL OVSDB Clustering':
72         command => "configure_cluster.sh ${::opendaylight::ha_node_index} ${ha_node_ip_str}",
73         path    => '/opt/opendaylight/bin/:/usr/sbin:/usr/bin:/sbin:/bin',
74         creates => '/opt/opendaylight/configuration/initial/akka.conf'
75       }
76     } else {
77       fail("Number of HA nodes less than 2: ${ha_node_count} and HA Enabled")
78     }
79   }
80
81   # Configure ACL security group
82   # Requires at least CentOS 7.3 for RHEL/CentOS systems
83   if ('odl-netvirt-openstack' in $opendaylight::features) {
84     if $opendaylight::security_group_mode == 'stateful' {
85       if defined('$opendaylight::stateful_unsupported') {
86         if $opendaylight::stateful_unsupported {
87           warning("Stateful is unsupported in ${::operatingsystemrelease} setting to 'learn'")
88           $sg_mode = 'learn'
89         } else {
90             $sg_mode = 'learn'
91         }
92       } else {
93         $sg_mode = 'stateful'
94       }
95     } else {
96       $sg_mode = $opendaylight::security_group_mode
97     }
98
99     $odl_datastore = [
100       '/opt/opendaylight/etc/opendaylight',
101       '/opt/opendaylight/etc/opendaylight/datastore',
102       '/opt/opendaylight/etc/opendaylight/datastore/initial',
103       '/opt/opendaylight/etc/opendaylight/datastore/initial/config',
104     ]
105
106     file { $odl_datastore:
107       ensure => directory,
108       mode   => '0755',
109       owner  => 'odl',
110       group  => 'odl',
111     }
112     ->
113     file { 'netvirt-aclservice-config.xml':
114       ensure  => file,
115       path    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-aclservice-config.xml',
116       owner   => 'odl',
117       group   => 'odl',
118       content => template('opendaylight/netvirt-aclservice-config.xml.erb'),
119     }
120   }
121 }