56c4909e788f02aea0683a97617122b505e7ab02
[integration/packaging/puppet-opendaylight.git] / manifests / install.pp
1 # == Class opendaylight::install
2 #
3 # Manages the installation of OpenDaylight.
4 #
5 # There are two install methods: RPM-based and deb-based. The resulting
6 # system state should be functionally equivalent.
7 #
8 class opendaylight::install {
9   if $::osfamily == 'RedHat' {
10     # Add OpenDaylight's Yum repository
11     yumrepo { $opendaylight::rpm_repo:
12       # 'ensure' isn't supported with Puppet <3.5
13       # Seems to default to present, but docs don't say
14       # https://docs.puppetlabs.com/references/3.4.0/type.html#yumrepo
15       # https://docs.puppetlabs.com/references/3.5.0/type.html#yumrepo
16       baseurl  => "http://cbs.centos.org/repos/nfv7-${opendaylight::rpm_repo}/\$basearch/os/",
17       descr    => 'OpenDaylight SDN Controller',
18       enabled  => 1,
19       # NB: RPM signing is an active TODO, but is not done. We will enable
20       #     this gpgcheck once the RPM supports it.
21       gpgcheck => 0,
22       before   => Package['opendaylight'],
23     }
24
25     # Install the OpenDaylight RPM
26     package { 'opendaylight':
27       ensure  => present,
28       require => Yumrepo[$opendaylight::rpm_repo],
29     }
30     ->
31     # Configure the systemd file with Java options
32     file_line { 'java_options_systemd':
33       ensure => present,
34       path   => '/usr/lib/systemd/system/opendaylight.service',
35       line   => "Environment=_JAVA_OPTIONS=\'${opendaylight::java_opts}\'",
36       match  => '^Environment.*',
37       after  => 'ExecStart=/opt/opendaylight/bin/start',
38     }
39     ~>
40     exec {'reload_systemd_units':
41       command     => 'systemctl daemon-reload',
42       path        => '/bin',
43       refreshonly => true,
44     }
45   }
46
47   elsif $::osfamily == 'Debian'{
48
49     include apt
50
51     # Add ODL ppa repository
52     apt::ppa{ $opendaylight::deb_repo: }
53
54     # Install Opendaylight .deb pkg
55     package { 'opendaylight':
56       ensure  => present,
57       require => Apt::Ppa[$opendaylight::deb_repo],
58     }
59
60     Apt::Ppa[$opendaylight::deb_repo] -> Package['opendaylight']
61   }
62   else {
63     fail("Unknown operating system method: ${::osfamily}")
64   }
65 }