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