97e182c984369b2c71b778ee1d8f2075be4b14dd
[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   # Configure ODL HA if enabled
43   $ha_node_count = count($::opendaylight::ha_node_ips)
44   if $::opendaylight::enable_ha {
45     if $ha_node_count >= 2 {
46       # Configure ODL OSVDB Clustering
47       $ha_node_ip_str = join($::opendaylight::ha_node_ips, ' ')
48       exec { 'Configure ODL OVSDB Clustering':
49         command => "configure_cluster.sh ${::opendaylight::ha_node_index} ${ha_node_ip_str}",
50         path    => '/opt/opendaylight/bin/:/usr/sbin:/usr/bin:/sbin:/bin',
51         creates => '/opt/opendaylight/configuration/initial/akka.conf'
52       }
53     } else {
54       fail("Number of HA nodes less than 2: ${ha_node_count} and HA Enabled")
55     }
56   }
57
58   # Configure ACL security group
59   # Requires at least CentOS 7.3 for RHEL/CentOS systems
60   if ('odl-netvirt-openstack' in $opendaylight::features) {
61     if $opendaylight::security_group_mode == 'stateful' {
62       if defined('$opendaylight::stateful_unsupported') and $opendaylight::stateful_unsupported {
63           warning("Stateful is unsupported in ${::operatingsystemrelease} setting to 'learn'")
64           $sg_mode = 'learn'
65       } else {
66         $sg_mode = 'stateful'
67       }
68     } else {
69       $sg_mode = $opendaylight::security_group_mode
70     }
71
72     $odl_datastore = [
73       '/opt/opendaylight/etc/opendaylight',
74       '/opt/opendaylight/etc/opendaylight/datastore',
75       '/opt/opendaylight/etc/opendaylight/datastore/initial',
76       '/opt/opendaylight/etc/opendaylight/datastore/initial/config',
77     ]
78
79     file { $odl_datastore:
80       ensure => directory,
81       mode   => '0755',
82       owner  => 'odl',
83       group  => 'odl',
84     }
85     -> file { 'netvirt-aclservice-config.xml':
86       ensure  => file,
87       path    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-aclservice-config.xml',
88       owner   => 'odl',
89       group   => 'odl',
90       content => template('opendaylight/netvirt-aclservice-config.xml.erb'),
91     }
92   }
93
94   #configure VPP routing node
95   if ! empty($::opendaylight::vpp_routing_node) {
96     file { 'org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg':
97       ensure => file,
98       path   => '/opt/opendaylight/etc/org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg',
99       owner  => 'odl',
100       group  => 'odl',
101     }
102     file_line { 'routing-node':
103       path  => '/opt/opendaylight/etc/org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg',
104       line  => "routing-node=${::opendaylight::vpp_routing_node}",
105       match => '^routing-node=.*$',
106     }
107   }
108
109   # Configure username/password
110   odl_user { $::opendaylight::username:
111     password => $::opendaylight::password,
112     before   => Service['opendaylight'],
113   }
114 }