1 # == Class opendaylight::config
3 # This class handles ODL config changes.
4 # It's called from the opendaylight class.
6 class opendaylight::config {
7 # Configuration of Karaf features to install
8 file { 'org.apache.karaf.features.cfg':
10 path => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
11 # Set user:group owners
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=.*$',
22 # Modify karaf to include Java options
23 file_line {'Karaf Java Options':
25 path => '/opt/opendaylight/bin/karaf',
26 line => "EXTRA_JAVA_OPTS=${opendaylight::java_opts}",
27 match => '^EXTRA_JAVA_OPTS=.*$',
28 after => '^PROGNAME=.*$'
31 file { 'org.ops4j.pax.web.cfg':
33 path => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
34 # Set user:group owners
39 $ha_node_count = count($::opendaylight::ha_node_ips)
40 if $::opendaylight::enable_ha and $ha_node_count < 2 {
41 fail("Number of HA nodes less than 2: ${ha_node_count} and HA Enabled")
44 # Configuration of ODL NB REST port to listen on
45 if $opendaylight::enable_tls {
47 if $::opendaylight::tls_keystore_password == undef {
48 fail('Enabling TLS requires setting a TLS password for the ODL keystore')
51 if $::opendaylight::tls_key_file or $::opendaylight::tls_cert_file {
52 if $::opendaylight::tls_key_file and $::opendaylight::tls_cert_file {
53 odl_keystore { 'controller':
54 password => $::opendaylight::tls_keystore_password,
55 cert_file => $::opendaylight::tls_cert_file,
56 key_file => $::opendaylight::tls_key_file,
57 ca_file => $::opendaylight::tls_ca_cert_file,
58 require => File['/opt/opendaylight/configuration/ssl']
61 fail('Must specify both TLS key file path AND certificate file path')
65 augeas {'Remove HTTP ODL REST Port':
66 incl => '/opt/opendaylight/etc/jetty.xml',
67 context => '/files/opt/opendaylight/etc/jetty.xml/Configure',
69 changes => ["rm Call[1]/Arg/New/Set[#attribute[name='port']]"]
72 augeas {'ODL SSL REST Port':
73 incl => '/opt/opendaylight/etc/jetty.xml',
74 context => '/files/opt/opendaylight/etc/jetty.xml/Configure',
76 changes => ["set New[1]/Set[#attribute[name='securePort']]/Property/#attribute/default ${opendaylight::odl_rest_port}"]
79 file_line { 'set pax TLS port':
81 path => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
82 line => "org.osgi.service.http.port.secure = ${opendaylight::odl_rest_port}",
83 match => '^#?org.osgi.service.http.port.secure.*$',
84 require => File['org.ops4j.pax.web.cfg']
87 file_line { 'enable pax TLS':
89 path => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
90 line => 'org.osgi.service.http.secure.enabled = true',
91 match => '^#?org.osgi.service.http.secure.enabled.*$',
92 require => File['org.ops4j.pax.web.cfg']
95 file_line { 'disable pax HTTP':
97 path => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
98 line => 'org.osgi.service.http.enabled = false',
99 match => '^#?org.osgi.service.http.enabled.*$',
100 require => File['org.ops4j.pax.web.cfg']
103 file {'aaa-cert-config.xml':
105 path => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/aaa-cert-config.xml',
108 content => template('opendaylight/aaa-cert-config.xml.erb'),
111 file_line {'set pax TLS keystore location':
113 path => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
114 line => 'org.ops4j.pax.web.ssl.keystore = configuration/ssl/ctl.jks',
115 match => '^#?org.ops4j.pax.web.ssl.keystore.*$',
116 require => File['org.ops4j.pax.web.cfg']
118 file_line {'set pax TLS keystore integrity password':
120 path => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
121 line => "org.ops4j.pax.web.ssl.password = ${opendaylight::tls_keystore_password}",
122 match => '^#?org.ops4j.pax.web.ssl.password.*$',
123 require => File['org.ops4j.pax.web.cfg']
126 file_line {'set pax TLS keystore password':
128 path => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
129 line => "org.ops4j.pax.web.ssl.keypassword = ${opendaylight::tls_keystore_password}",
130 match => '^#?org.ops4j.pax.web.ssl.keypassword.*$',
131 require => File['org.ops4j.pax.web.cfg']
134 # Enable TLS with OVSDB
135 file { 'org.opendaylight.ovsdb.library.cfg':
137 path => '/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg',
140 source => 'puppet:///modules/opendaylight/org.opendaylight.ovsdb.library.cfg',
143 # Configure OpenFlow plugin to use TLS
144 $transport_protocol = 'TLS'
146 $transport_protocol = 'TCP'
147 augeas { 'ODL REST Port':
148 incl => '/opt/opendaylight/etc/jetty.xml',
149 context => '/files/opt/opendaylight/etc/jetty.xml/Configure',
152 "set Call[1]/Arg/New/Set[#attribute[name='port']]/Property/#attribute/default
153 ${opendaylight::odl_rest_port}"]
156 file_line { 'set pax bind port':
158 path => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
159 line => "org.osgi.service.http.port = ${opendaylight::odl_rest_port}",
160 match => '^#?org.osgi.service.http.port\s.*$',
161 require => File['org.ops4j.pax.web.cfg']
164 # Configure OpenFlow plugin to use TCP/TLS
165 file { 'default-openflow-connection-config.xml':
167 path => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/default-openflow-connection-config.xml',
168 # Set user:group owners
171 content => template('opendaylight/default-openflow-connection-config.xml.erb'),
173 $initial_config_dir = '/opt/opendaylight/configuration/initial'
175 file { $initial_config_dir:
182 if $opendaylight::odl_bind_ip != '0.0.0.0' {
183 # Configuration of ODL NB REST IP to listen on
184 augeas { 'ODL REST IP':
185 incl => '/opt/opendaylight/etc/jetty.xml',
186 context => '/files/opt/opendaylight/etc/jetty.xml/Configure',
189 "set Call[1]/Arg/New/Set[#attribute[name='host']]/Property/#attribute/default ${opendaylight::odl_bind_ip}"
193 # Configure karaf bind IP
194 file_line { 'set karaf IP':
196 path => '/opt/opendaylight/etc/org.apache.karaf.shell.cfg',
197 line => "sshHost = ${opendaylight::odl_bind_ip}",
198 match => '^sshHost\s*=.*$',
201 file_line { 'set pax bind IP':
203 path => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
204 line => "org.ops4j.pax.web.listening.addresses = ${opendaylight::odl_bind_ip}",
205 require => File['org.ops4j.pax.web.cfg']
208 # Configure websocket address
209 file { '/opt/opendaylight/etc/org.opendaylight.restconf.cfg':
211 path => '/opt/opendaylight/etc/org.opendaylight.restconf.cfg',
215 -> file_line { 'websocket-address':
217 path => '/opt/opendaylight/etc/org.opendaylight.restconf.cfg',
218 line => "websocket-address=${::opendaylight::odl_bind_ip}",
219 match => '^websocket-address=.*$',
223 # Set any custom log levels
224 $opendaylight::log_levels.each |$log_name, $logging_level| {
225 $underscored_version = regsubst($log_name, '\.', '_', 'G')
226 file_line {"logger-${log_name}-level":
228 path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
229 line => "log4j2.logger.${underscored_version}.level = ${logging_level}",
230 match => "log4j2.logger.${underscored_version}.level = .*$"
232 file_line {"logger-${log_name}-name":
234 path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
235 line => "log4j2.logger.${underscored_version}.name = ${log_name}",
236 match => "log4j2.logger.${underscored_version}.name = .*$"
240 # set logging mechanism
241 if $opendaylight::log_mechanism == 'console' {
242 file_line { 'consoleappender':
244 path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
245 line => 'karaf.log.console=INFO',
246 after => 'log4j2.rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter',
247 match => '^karaf.log.console.*$'
249 file_line { 'direct':
251 path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
252 line => 'log4j2.appender.console.direct = true',
253 after => 'karaf.log.console=INFO',
254 match => '^log4j2.appender.console.direct.*$'
258 # Set maximum ODL log file size
259 file_line { 'logmaxsize':
261 path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
262 line => "log4j2.appender.rolling.policies.size.size = ${::opendaylight::log_max_size}",
263 match => '^log4j2.appender.rolling.policies.size.size.*$'
266 file_line { 'rolloverstrategy':
268 path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
269 line => 'log4j2.appender.rolling.strategy.type = DefaultRolloverStrategy'
272 # Set maximum number of ODL log file rollovers to preserve
273 -> file_line { 'logmaxrollover':
275 path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
276 line => "log4j2.appender.rolling.strategy.max = ${::opendaylight::log_max_rollover}",
277 match => '^log4j2.appender.rolling.strategy.max.*$'
281 # Configure ODL HA if enabled
282 if $::opendaylight::enable_ha {
283 # Configure ODL OSVDB Clustering
287 path => "${initial_config_dir}/akka.conf",
290 content => template('opendaylight/akka.conf.erb'),
291 require => File[$initial_config_dir]
294 file {'modules.conf':
296 path => "${initial_config_dir}/modules.conf",
299 content => template('opendaylight/modules.conf.erb'),
300 require => File[$initial_config_dir]
303 file {'module-shards.conf':
305 path => "${initial_config_dir}/module-shards.conf",
308 content => template('opendaylight/module-shards.conf.erb'),
309 require => File[$initial_config_dir]
314 '/opt/opendaylight/etc/opendaylight',
315 '/opt/opendaylight/etc/opendaylight/karaf',
316 '/opt/opendaylight/etc/opendaylight/datastore',
317 '/opt/opendaylight/etc/opendaylight/datastore/initial',
318 '/opt/opendaylight/etc/opendaylight/datastore/initial/config',
319 '/opt/opendaylight/configuration/ssl'
329 if ('odl-netvirt-openstack' in $opendaylight::features or 'odl-netvirt-sfc' in $opendaylight::features) {
332 file { 'netvirt-natservice-config.xml':
334 path => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml',
337 content => template('opendaylight/netvirt-natservice-config.xml.erb'),
338 require => File['/opt/opendaylight/etc/opendaylight/datastore/initial/config'],
342 # Config file for SFC and DSCP features
343 file { 'genius-itm-config.xml':
345 path => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml',
348 content => template('opendaylight/genius-itm-config.xml.erb'),
349 require => File['/opt/opendaylight/etc/opendaylight/datastore/initial/config'],
352 #configure VPP routing node
353 if ! empty($::opendaylight::vpp_routing_node) {
354 file { 'org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg':
356 path => '/opt/opendaylight/etc/org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg',
360 file_line { 'routing-node':
361 path => '/opt/opendaylight/etc/org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg',
362 line => "routing-node=${::opendaylight::vpp_routing_node}",
363 match => '^routing-node=.*$',
367 # Configure username/password
368 odl_user { $::opendaylight::username:
369 password => $::opendaylight::password,
370 before => Service['opendaylight'],