1 # == Class opendaylight::install
3 # Manages the installation of OpenDaylight.
5 # There are two install methods: RPM-based and tarball-based. The resulting
6 # system state should be functionally equivalent, but we have to do more
7 # work here for the tarball method (would normally be handled by the RPM).
9 class opendaylight::install {
10 if $opendaylight::install_method == 'rpm' {
11 # Choose Yum URL based on OS (CentOS vs Fedora)
12 # NB: Currently using the CentOS CBS for both Fedora and CentOS
13 $base_url = $::operatingsystem ? {
14 'CentOS' => 'http://cbs.centos.org/repos/nfv7-opendaylight-3-candidate/$basearch/os/',
15 'Fedora' => 'http://cbs.centos.org/repos/nfv7-opendaylight-3-candidate/$basearch/os/',
18 # Add OpenDaylight's Yum repository
19 yumrepo { 'opendaylight-3-candidate':
20 # 'ensure' isn't supported with Puppet <3.5
21 # Seems to default to present, but docs don't say
22 # https://docs.puppetlabs.com/references/3.4.0/type.html#yumrepo
23 # https://docs.puppetlabs.com/references/3.5.0/type.html#yumrepo
25 descr => 'CentOS CBS OpenDaylight Lithium candidate repository',
27 # NB: RPM signing is an active TODO, but is not done. We will enable
28 # this gpgcheck once the RPM supports it.
30 before => Package['opendaylight'],
33 # Install the OpenDaylight RPM
34 package { 'opendaylight':
36 require => Yumrepo['opendaylight-3-candidate'],
39 elsif $opendaylight::install_method == 'tarball' {
41 $package = $::osfamily ? {
42 'RedHat' => 'java-1.7.0-openjdk',
43 'Debian' => 'openjdk-7-jdk',
46 # NB: ODL is currently in the process of moving to Java 8
50 # Create and configure the odl user
53 # Must be a valid dir for the auto-creation of some files
54 home => '/opt/opendaylight/',
55 # The odl user should, at the minimum, be a member of the odl group
56 membership => 'minimum',
58 # The odl user's home dir should exist before the user is created
59 # The odl group, to which the odl user will belong, should exist
60 require => [Archive['opendaylight'], Group['odl']],
61 # The odl user will own this dir, user should exist before we set owner
62 before => File['/opt/opendaylight/'],
65 # Create and configure the odl group
68 # The odl user will be a member of this group, create it first
69 # The odl user will own ODL's dir, so should exist before owner set
70 before => [File['/opt/opendaylight/'], User['odl']],
73 # Download and extract the ODL tarball
74 archive { 'opendaylight':
76 # URL from which ODL's tarball can be downloaded
77 url => $opendaylight::tarball_url,
78 # Will end up installing /opt/opendaylight/
79 target => '/opt/opendaylight/',
80 # ODL doesn't provide a checksum in the expected path, would fail
82 # This discards top-level dir of extracted tarball
83 # Required to get proper /opt/opendaylight/ path
84 strip_components => 1,
85 # Default timeout is 120s, which may not be enough. See Issue #53:
86 # https://github.com/dfarrell07/puppet-opendaylight/issues/53
88 # ODL's archive should be dl'd/extracted before we config mode/user/group
89 # The odl user will set this to their home dir, should exist before user
90 before => [File['/opt/opendaylight/'], User['odl']],
93 # Set the user:group owners and mode of ODL dir
94 file { '/opt/opendaylight/':
95 # ensure=>dir and recurse=>true are required for managing recursively
96 ensure => 'directory',
98 # Set user:group owners of ODL dir
101 # The ODL archive we're modifying should exist
102 # Since ODL's dir is owned by odl:odl, that user:group should exist
103 require => [Archive['opendaylight'], Group['odl'], User['odl']],
106 # Systemd vs upstart config depends on OS family
107 if ( $::osfamily == 'RedHat' ) {
108 # Download ODL systemd .service file and put in right location
109 archive { 'opendaylight-systemd':
111 url => $opendaylight::unitfile_url,
112 # Will end up installing /usr/lib/systemd/system/opendaylight.service
113 target => '/usr/lib/systemd/system/',
114 # Required by archive mod for correct exec `creates` param
115 root_dir => 'opendaylight.service',
116 # ODL doesn't provide a checksum in the expected path, would fail
118 # This discards top-level dir of extracted tarball
119 # Required to get proper /opt/opendaylight-<version> path
120 strip_components => 1,
121 # May end up with an HTML redirect output in a text file without this
122 # Note that the curl'd down file would still have a .tar.gz name
123 follow_redirects => true,
124 # Should exist before we try to set its user/group/mode
125 before => File['/usr/lib/systemd/system/opendaylight.service'],
128 # Set the user:group owners and mode of ODL's systemd .service file
129 file { '/usr/lib/systemd/system/opendaylight.service':
130 # It should be a normal file
132 # Set user:group owners of ODL systemd .service file
135 # Set mode of ODL systemd .service file
137 # Should happen after the ODL systemd .service file has been extracted
138 require => Archive['opendaylight-systemd'],
141 elsif ( $::osfamily == 'Debian' ) {
142 file { '/etc/init/opendaylight.conf':
143 # It should be a normal file
145 # Set user:group owners of ODL upstart file
146 # NB: Unverfied, not sure if this is correct for upstart
149 # Set mode of ODL upstart file
150 # NB: Unverfied, not sure if this is correct for upstart
152 # Use Puppet URL for Travis. File stored in <mod name>/files/
153 source => 'puppet:///modules/opendaylight/upstart.odl.conf'
157 fail("Unsupported OS family: ${::osfamily}")
161 fail("Unknown install method: ${opendaylight::install_method}")