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