Refactors how install method is selected
[integration/packaging/puppet-opendaylight.git] / manifests / install.pp
1 # == Class opendaylight::install
2 #
3 # This class is called from opendaylight for install.
4 #
5 class opendaylight::install {
6   if $opendaylight::install_method == 'rpm' {
7     # Choose Yum URL based on OS (CentOS vs Fedora)
8     $base_url = $::operatingsystem ? {
9       'CentOS' => 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/',
10       'Fedora' => 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/fedora-$releasever-$basearch/',
11     }
12
13     yumrepo { 'opendaylight':
14       # 'ensure' isn't supported with Puppet <3.5
15       # Seems to default to present, but docs don't say
16       # https://docs.puppetlabs.com/references/3.4.0/type.html#yumrepo
17       # https://docs.puppetlabs.com/references/3.5.0/type.html#yumrepo
18       baseurl  => $base_url,
19       descr    => 'OpenDaylight SDN controller',
20       gpgcheck => 0,
21       enabled  => 1,
22       before   => Package['opendaylight'],
23     }
24
25     package { 'opendaylight':
26       ensure  => present,
27       require => Yumrepo['opendaylight'],
28     }
29   }
30   elsif $opendaylight::install_method == 'tarball' {
31     # Download and extract the ODL tarball
32     archive { 'opendaylight-0.2.2':
33       ensure           => present,
34       url              => $opendaylight::tarball_url,
35       target           => '/opt/',
36       checksum         => false,
37       # This discards top-level dir of extracted tarball
38       # Required to get proper /opt/opendaylight-<version> path
39       # Ideally, camptocamp/puppet-archive would support this. PR later?
40       strip_components => 1,
41     }
42
43     # TODO: Download ODL systemd .service file and put in right location
44   }
45   else {
46     fail("Unknown install method: ${opendaylight::install_method}")
47   }
48 }