Binds OpenFlow and OVSDB IPs
[integration/packaging/puppet-opendaylight.git] / manifests / init.pp
1 # == Class: opendaylight
2 #
3 # OpenDaylight SDN Controller
4 #
5 # === Parameters
6 # [*default_features*]
7 #   Features that should normally be installed by default, but can be
8 #   overridden.
9 # [*extra_features*]
10 #   List of features to install in addition to the default ones.
11 # [*odl_rest_port *]
12 #   Port for ODL northbound REST interface to listen on.
13 # [*odl_bind_ip *]
14 #   IP for ODL northbound REST interface and southbound OVSDB/OpenFlow to bind to.
15 # [*rpm_repo*]
16 #   Repo URL to install ODL RPM from, in .repo baseurl format.
17 # [*deb_repo*]
18 #   OpenDaylight Launchpad PPA repo to install .deb from (ppa:odl-team/carbon,
19 #   ppa:odl-team/nitrogen, ...).
20 # [*log_levels*]
21 #   Custom OpenDaylight logger verbosity configuration (TRACE, DEBUG, INFO, WARN, ERROR).
22 # [*enable_ha*]
23 #   Enable or disable ODL OVSDB HA Clustering. Valid: true or false.
24 #   Default: false.
25 # [*ha_node_ips*]
26 #   Array of IPs for each node in the HA cluster.
27 # [*ha_db_modules*]
28 #   Hash of modules and Yang namespaces to create database shards.  Defaults to
29 #   { 'default' => false }.  "default" module does not need a namespace.
30 # [*vpp_routing_node*]
31 #   Sets routing node for VPP deployments. Defaults to ''.
32 # [*java_opts*]
33 #   Sets Java options for ODL in a string format. Defaults to ''.
34 # [*manage_repositories*]
35 #   (Boolean) Should this module manage the apt or yum repositories for the
36 #   package installation.
37 #   Defaults to true
38 # [*log_max_size*]
39 #   Maxium size of OpenDaylight's log file.
40 # [*log_max_rollover*]
41 #   Maxium number of OpenDaylight log rollovers to keep.
42 # [*log_rollover_fileindex*]
43 #   File index to use for OpenDaylight log rollovers
44 #   Defaults to 'min'.
45 #   Other possible values: 'max', 'nomax'
46 #   see https://logging.apache.org/log4j/2.x/manual/appenders.html#FileAppender for more info
47 # [*snat_mechanism*]
48 #   Sets the mechanism to be used for SNAT (conntrack, controller)
49 # [*enable_tls*]
50 #   (Boolean) Enables TLS for REST and OpenFlow/OVSDB with OpenDaylight.
51 #   Defaults to false
52 # [*tls_keystore_password*]
53 #   TLS keystore password.  Required when enabling TLS.
54 # [*tls_trusted_certs*]
55 #   An array of cert files to be added to OpenDaylight's trusted keystore.
56 #   Optional.  Defaults to None.
57 # [*tls_key_file*]
58 #   Full path to a private key file to be used for OpenDaylight.
59 #   Optional.  Defaults to undef.  Requires setting tls_cert_file.
60 # [*tls_cert_file*]
61 #   Full path to a public certificate file to be used for OpenDaylight.
62 #   Optional.  Defaults to undef.  Requires setting tls_key_file.
63 # [*tls_ca_cert_file*]
64 #   Full path to a public CA authority certificate file which signed
65 #   OpenDaylight's certificate.  Not needed if ODL certificate is self-signed.
66 #   Optional.  Defaults to undef.
67 # [*log_mechanism*]
68 #   Sets logging mechanism for karaf logs
69 # [*inherit_dscp_marking*]
70 #   Sets tos option to enable QoS DSCP marking
71 #   Defaults to false
72 # [*stats_polling_enabled*]
73 #   Enables statistics polling of OpenFlow entities like table, groups.
74 #   Defaults to false
75 #
76 # === Deprecated Parameters
77 #
78 # [*ha_node_index*]
79 #   Index of ha_node_ips for this node.
80 #
81 class opendaylight (
82   $default_features       = $::opendaylight::params::default_features,
83   $extra_features         = $::opendaylight::params::extra_features,
84   $odl_rest_port          = $::opendaylight::params::odl_rest_port,
85   $odl_bind_ip            = $::opendaylight::params::odl_bind_ip,
86   $rpm_repo               = $::opendaylight::params::rpm_repo,
87   $deb_repo               = $::opendaylight::params::deb_repo,
88   $log_levels             = $::opendaylight::params::log_levels,
89   $enable_ha              = $::opendaylight::params::enable_ha,
90   $ha_node_ips            = $::opendaylight::params::ha_node_ips,
91   $ha_node_index          = $::opendaylight::params::ha_node_index,
92   $java_opts              = $::opendaylight::params::java_opts,
93   $ha_db_modules          = $::opendaylight::params::ha_db_modules,
94   $vpp_routing_node       = $::opendaylight::params::vpp_routing_node,
95   $manage_repositories    = $::opendaylight::params::manage_repositories,
96   $username               = $::opendaylight::params::username,
97   $password               = $::opendaylight::params::password,
98   $log_max_size           = $::opendaylight::params::log_max_size,
99   $log_max_rollover       = $::opendaylight::params::log_max_rollover,
100   $log_rollover_fileindex = $::opendaylight::params::log_rollover_fileindex,
101   $snat_mechanism         = $::opendaylight::params::snat_mechanism,
102   $enable_tls             = $::opendaylight::params::enable_tls,
103   $tls_keystore_password  = $::opendaylight::params::tls_keystore_password,
104   $tls_trusted_certs      = $::opendaylight::params::tls_trusted_certs,
105   $tls_key_file           = $::opendaylight::params::tls_key_file,
106   $tls_cert_file          = $::opendaylight::params::tls_cert_file,
107   $tls_ca_cert_file       = $::opendaylight::params::tls_ca_cert_file,
108   $log_mechanism          = $::opendaylight::params::log_mechanism,
109   $inherit_dscp_marking   = $::opendaylight::params::inherit_dscp_marking,
110   $stats_polling_enabled  = $::opendaylight::params::stats_polling_enabled,
111 ) inherits ::opendaylight::params {
112
113   # Validate OS family
114   case $::osfamily {
115     'RedHat': {}
116     'Debian': {
117         warning('Debian has limited support, is less stable, less tested.')
118     }
119     default: {
120         fail("Unsupported OS family: ${::osfamily}")
121     }
122   }
123
124   # Validate OS
125   case $::operatingsystem {
126     centos, redhat: {
127       if $::operatingsystemmajrelease != '7' {
128         # RHEL/CentOS versions < 7 not supported as they lack systemd
129         fail("Unsupported OS: ${::operatingsystem} ${::operatingsystemmajrelease}")
130       }
131     }
132     fedora: {
133       # Fedora distros < 24 are EOL as of 2016-12-20
134       # https://fedoraproject.org/wiki/End_of_life
135       if $::operatingsystemmajrelease < '24' {
136         fail("Unsupported OS: ${::operatingsystem} ${::operatingsystemmajrelease}")
137       } else {
138         warning('Fedora is not as well tested as CentOS.')
139       }
140     }
141     ubuntu: {
142       if $::operatingsystemrelease < '16.04' {
143         # Only tested on 16.04
144         fail("Unsupported OS: ${::operatingsystem} ${::operatingsystemrelease}")
145       }
146     }
147     default: {
148       fail("Unsupported OS: ${::operatingsystem}")
149     }
150   }
151   # Build full list of features to install
152   $features = union($default_features, $extra_features)
153
154   if $opendaylight::odl_bind_ip =~ Stdlib::Compat::Ipv6 {
155     $enable_ipv6 = true
156     $java_options = join(union(['-Djava.net.preferIPv6Addresses=true'], any2array($opendaylight::java_opts)), ' ')
157   }
158   else {
159     $enable_ipv6 = false
160     $java_options = join(union(['-Djava.net.preferIPv4Stack=true'], any2array($opendaylight::java_opts)), ' ')
161   }
162
163   class { '::opendaylight::install': }
164   -> class { '::opendaylight::config': }
165   ~> class { '::opendaylight::service': }
166   -> class { '::opendaylight::post_config': }
167   -> Class['::opendaylight']
168 }