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 $base_url = $::operatingsystem ? {
13 'CentOS' => 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/',
14 'Fedora' => 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/fedora-$releasever-$basearch/',
17 # Add OpenDaylight's Yum repository
18 yumrepo { 'opendaylight':
19 # 'ensure' isn't supported with Puppet <3.5
20 # Seems to default to present, but docs don't say
21 # https://docs.puppetlabs.com/references/3.4.0/type.html#yumrepo
22 # https://docs.puppetlabs.com/references/3.5.0/type.html#yumrepo
24 descr => 'OpenDaylight SDN controller',
27 before => Package['opendaylight'],
30 # Install the OpenDaylight RPM
31 package { 'opendaylight':
33 require => Yumrepo['opendaylight'],
36 elsif $opendaylight::install_method == 'tarball' {
38 $package = $::osfamily ? {
39 'RedHat' => 'java-1.7.0-openjdk',
40 'Debian' => 'java7-jdk',
43 # NB: ODL is currently in the process of moving to Java 8
47 # Create and configure the odl user
50 # Must be a valid dir for the auto-creation of some files
51 home => '/opt/opendaylight/',
52 # The odl user should, at the minimum, be a member of the odl group
53 membership => 'minimum',
55 # The odl user's home dir should exist before the user is created
56 # The odl group, to which the odl user will belong, should exist
57 require => [Archive['opendaylight'], Group['odl']],
58 # The odl user will own this dir, user should exist before we set owner
59 before => File['/opt/opendaylight/'],
62 # Create and configure the odl group
65 # The odl user will be a member of this group, create it first
66 # The odl user will own ODL's dir, so should exist before owner set
67 before => [File['/opt/opendaylight/'], User['odl']],
70 # Download and extract the ODL tarball
71 archive { 'opendaylight':
73 # URL from which ODL's tarball can be downloaded
74 url => $opendaylight::tarball_url,
75 # Will end up installing /opt/opendaylight/
76 target => '/opt/opendaylight/',
77 # ODL doesn't provide a checksum in the expected path, would fail
79 # This discards top-level dir of extracted tarball
80 # Required to get proper /opt/opendaylight/ path
81 strip_components => 1,
82 # Default timeout is 120s, which may not be enough. See Issue #53:
83 # https://github.com/dfarrell07/puppet-opendaylight/issues/53
85 # ODL's archive should be dl'd/extracted before we config mode/user/group
86 # The odl user will set this to their home dir, should exist before user
87 before => [File['/opt/opendaylight/'], User['odl']],
90 # Set the user:group owners and mode of ODL dir
91 file { '/opt/opendaylight/':
92 # ensure=>dir and recurse=>true are required for managing recursively
93 ensure => 'directory',
95 # Set user:group owners of ODL dir
98 # The ODL archive we're modifying should exist
99 # Since ODL's dir is owned by odl:odl, that user:group should exist
100 require => [Archive['opendaylight'], Group['odl'], User['odl']],
103 # Systemd vs upstart config depends on OS family
104 if ( $::osfamily == 'RedHat' ) {
105 # Download ODL systemd .service file and put in right location
106 archive { 'opendaylight-systemd':
108 url => $opendaylight::unitfile_url,
109 # Will end up installing /usr/lib/systemd/system/opendaylight.service
110 target => '/usr/lib/systemd/system/',
111 # Required by archive mod for correct exec `creates` param
112 root_dir => 'opendaylight.service',
113 # ODL doesn't provide a checksum in the expected path, would fail
115 # This discards top-level dir of extracted tarball
116 # Required to get proper /opt/opendaylight-<version> path
117 strip_components => 1,
118 # May end up with an HTML redirect output in a text file without this
119 # Note that the curl'd down file would still have a .tar.gz name
120 follow_redirects => true,
121 # Should exist before we try to set its user/group/mode
122 before => File['/usr/lib/systemd/system/opendaylight.service'],
125 # Set the user:group owners and mode of ODL's systemd .service file
126 file { '/usr/lib/systemd/system/opendaylight.service':
127 # It should be a normal file
129 # Set user:group owners of ODL systemd .service file
132 # Set mode of ODL systemd .service file
134 # Should happen after the ODL systemd .service file has been extracted
135 require => Archive['opendaylight-systemd'],
138 elsif ( $::osfamily == 'Debian' ) {
139 file { '/etc/init/opendaylight.conf':
140 # It should be a normal file
142 # Set user:group owners of ODL upstart file
143 # NB: Unverfied, not sure if this is correct for upstart
146 # Set mode of ODL upstart file
147 # NB: Unverfied, not sure if this is correct for upstart
149 # Use Puppet URL for Travis. File stored in opendaylight/files/
150 content => 'puppet:///modules/opendaylight/upstart.odl.conf'
154 fail("Unsupported OS family: ${::osfamily}")
158 fail("Unknown install method: ${opendaylight::install_method}")