Fixes configuring jetty.xml
[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 and IP to listen on
23   augeas {'jetty.xml':
24     incl    => '/opt/opendaylight/etc/jetty.xml',
25     context => '/files/opt/opendaylight/etc/jetty.xml/Configure',
26     lens    => 'Xml.lns',
27     changes => [
28       "set Call[2]/Arg/New/Set[#attribute[name='port']]/Property/#attribute/default ${opendaylight::odl_rest_port}",
29       "set Call[1]/Arg/New/Set[#attribute[name='host']]/#text[1] ${opendaylight::odl_bind_ip}",
30       "rm Call[1]/Arg/New/Set[#attribute[name='host']]/Property",
31       "set Call[2]/Arg/New/Set[#attribute[name='host']]/#text[1] ${opendaylight::odl_bind_ip}",
32       "rm Call[2]/Arg/New/Set[#attribute[name='host']]/Property"]
33   }
34
35   # Set any custom log levels
36   $opendaylight::log_levels.each |$log_name, $logging_level| {
37     file_line {"logger-${log_name}":
38       ensure => present,
39       path   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
40       line   => "log4j.logger.${log_name}=${logging_level}"
41     }
42   }
43
44   # Set maximum ODL log file size
45   file_line { 'logmaxsize':
46     ensure => present,
47     path   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
48     line   => "log4j.appender.out.maxFileSize=${::opendaylight::log_max_size}",
49     match  => '^log4j.appender.out.maxFileSize.*$'
50   }
51
52   # Set maximum number of ODL log file rollovers to preserve
53   file_line { 'logmaxrollover':
54     ensure => present,
55     path   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
56     line   => "log4j.appender.out.maxBackupIndex=${::opendaylight::log_max_rollover}",
57     match  => '^log4j.appender.out.maxBackupIndex.*$'
58   }
59
60   # Configure ODL HA if enabled
61   $ha_node_count = count($::opendaylight::ha_node_ips)
62   if $::opendaylight::enable_ha {
63     if $ha_node_count >= 2 {
64       # Configure ODL OSVDB Clustering
65       $cluster_config_dir = '/opt/opendaylight/configuration/initial'
66
67       file { $cluster_config_dir:
68         ensure => directory,
69         mode   => '0755',
70         owner  => 'odl',
71         group  => 'odl',
72       }
73
74       file {'akka.conf':
75         ensure  => file,
76         path    => "${cluster_config_dir}/akka.conf",
77         owner   => 'odl',
78         group   => 'odl',
79         content => template('opendaylight/akka.conf.erb'),
80         require => File[$cluster_config_dir]
81       }
82
83       file {'modules.conf':
84         ensure  => file,
85         path    => "${cluster_config_dir}/modules.conf",
86         owner   => 'odl',
87         group   => 'odl',
88         content => template('opendaylight/modules.conf.erb'),
89         require => File[$cluster_config_dir]
90       }
91
92       file {'module-shards.conf':
93         ensure  => file,
94         path    => "${cluster_config_dir}/module-shards.conf",
95         owner   => 'odl',
96         group   => 'odl',
97         content => template('opendaylight/module-shards.conf.erb'),
98         require => File[$cluster_config_dir]
99       }
100
101     } else {
102       fail("Number of HA nodes less than 2: ${ha_node_count} and HA Enabled")
103     }
104   }
105
106   if ('odl-netvirt-openstack' in $opendaylight::features or 'odl-netvirt-sfc' in $opendaylight::features) {
107     # Configure ACL security group
108     # Requires at least CentOS 7.3 for RHEL/CentOS systems
109     if $opendaylight::security_group_mode == 'stateful' {
110       if defined('$opendaylight::stateful_unsupported') and $opendaylight::stateful_unsupported {
111           warning("Stateful is unsupported in ${::operatingsystemrelease} setting to 'learn'")
112           $sg_mode = 'learn'
113       } else {
114         $sg_mode = 'stateful'
115       }
116     } else {
117       $sg_mode = $opendaylight::security_group_mode
118     }
119
120     $odl_datastore = [
121       '/opt/opendaylight/etc/opendaylight',
122       '/opt/opendaylight/etc/opendaylight/datastore',
123       '/opt/opendaylight/etc/opendaylight/datastore/initial',
124       '/opt/opendaylight/etc/opendaylight/datastore/initial/config',
125     ]
126
127     file { $odl_datastore:
128       ensure => directory,
129       mode   => '0755',
130       owner  => 'odl',
131       group  => 'odl',
132     }
133     -> file { 'netvirt-aclservice-config.xml':
134       ensure  => file,
135       path    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-aclservice-config.xml',
136       owner   => 'odl',
137       group   => 'odl',
138       content => template('opendaylight/netvirt-aclservice-config.xml.erb'),
139     }
140
141     # Configure SNAT
142     file { 'netvirt-natservice-config.xml':
143       ensure  => file,
144       path    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml',
145       owner   => 'odl',
146       group   => 'odl',
147       content => template('opendaylight/netvirt-natservice-config.xml.erb'),
148       require => File['/opt/opendaylight/etc/opendaylight/datastore/initial/config'],
149     }
150   }
151
152   # SFC Config
153   if ('odl-netvirt-sfc' in $opendaylight::features) {
154     file { 'netvirt-elanmanager-config.xml':
155       ensure  => file,
156       path    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-elanmanager-config.xml',
157       owner   => 'odl',
158       group   => 'odl',
159       source  => 'puppet:///modules/opendaylight/netvirt-elanmanager-config.xml',
160       require => File['/opt/opendaylight/etc/opendaylight/datastore/initial/config'],
161     }
162
163     file { 'genius-itm-config.xml':
164       ensure  => file,
165       path    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml',
166       owner   => 'odl',
167       group   => 'odl',
168       source  => 'puppet:///modules/opendaylight/genius-itm-config.xml',
169       require => File['/opt/opendaylight/etc/opendaylight/datastore/initial/config'],
170     }
171   }
172
173   #configure VPP routing node
174   if ! empty($::opendaylight::vpp_routing_node) {
175     file { 'org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg':
176       ensure => file,
177       path   => '/opt/opendaylight/etc/org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg',
178       owner  => 'odl',
179       group  => 'odl',
180     }
181     file_line { 'routing-node':
182       path  => '/opt/opendaylight/etc/org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg',
183       line  => "routing-node=${::opendaylight::vpp_routing_node}",
184       match => '^routing-node=.*$',
185     }
186   }
187
188   # Configure username/password
189   odl_user { $::opendaylight::username:
190     password => $::opendaylight::password,
191     before   => Service['opendaylight'],
192   }
193 }