This patch adds .deb support to puppet-odl. It adds beaker tests for Ubuntu 16.04.
This removes the tarball install method logic for both RedHat and Debian based OSs.
It adds logic that looks at the OS and decides the install repo: `rpm_repo` or `deb_repo`.
Addtionally, this patch adds `lsbdist`* facts for Ubuntu tests.
This also updates the README.md to reflect these changes.
Change-Id: I05490087b57dd04558388c68d67a390d10ca52c6
Signed-off-by: Akshita Jha <zenith158@gmail.com>
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
+ apt: "https://github.com/puppetlabs/puppetlabs-apt.git"
archive: "https://github.com/dfarrell07/puppet-archive"
java: "https://github.com/puppetlabs/puppetlabs-java"
symlinks:
- [Beginning with `opendaylight`](#beginning-with-opendaylight)
4. [Usage](#usage)
- [Karaf Features](#karaf-features)
- - [Install Method](#install-method)
- [RPM Repo](#rpm-repo)
+ - [Deb Repo](#deb-repo)
- [Ports](#ports)
- [Log Verbosity](#log-verbosity)
- [Enabling ODL OVSDB HA](#enabling-odl-ovsdb-ha)
## Module Description
-Deploys OpenDaylight to various OSs either via an RPM or directly from the
-ODL tarball release artifact.
+Deploys OpenDaylight to various OSs either via an RPM or a Deb.
All OpenDaylight configuration should be handled through the ODL Puppet
module's [params](#parameters). If you need a new knob, [please raise an
Issue][8].
-The master branch installs OpenDaylight from the latest testing RPM repository
-by default. There are stable/<release> branches that install OpenDaylight
-releases and service releases, like Beryllium or Beryllium SR3.
+By default, the master branch installs OpenDaylight from the latest testing RPM repository
+or from the latest stable Deb repository depending on the OS. There are stable/<release>
+branches that install OpenDaylight releases and service releases, like Beryllium or Beryllium SR3.
## Setup
- Installs Java, which is required by ODL.
- Creates `odl:odl` user:group if they don't already exist.
- Installs [OpenDaylight][7].
-- Installs a [systemd unitfile][9] or [Upstart config file][10] for
- OpenDaylight.
+- Installs a [systemd unitfile][9] for OpenDaylight.
- Manipulates OpenDaylight's configuration files according to the params
passed to the `::opendaylight` class.
-- Starts the `opendaylight` systemd or Upstart service.
+- Starts the `opendaylight` systemd service.
### Beginning with `opendaylight`
the `::opendaylight` class.
The [vagrant-opendaylight][11] project provides an easy way to experiment
-with [applying the ODL Puppet module][12] to CentOS 7, Fedora 22 and Fedora
-23 Vagrant boxes.
+with [applying the ODL Puppet module][12] to CentOS 7, Fedora 22, Fedora
+23 and Ubuntu 16.04 Vagrant boxes.
```
[~/vagrant-opendaylight]$ vagrant status
Current machine states:
-cent7 not created (libvirt)
-cent7_rpm_he_sr4 not created (libvirt)
-cent7_rpm_li_sr2 not created (libvirt)
-cent7_rpm_be not created (libvirt)
-cent7_ansible not created (libvirt)
-cent7_ansible_be not created (libvirt)
-cent7_ansible_path not created (libvirt)
-cent7_pup_rpm not created (libvirt)
-cent7_pup_custom_logs not created (libvirt)
-cent7_pup_tb not created (libvirt)
-f22_rpm_li not created (libvirt)
-f22_ansible not created (libvirt)
-f22_pup_rpm not created (libvirt)
-f23_rpm_li not created (libvirt)
-f23_rpm_li_sr1 not created (libvirt)
-f23_rpm_li_sr2 not created (libvirt)
-f23_rpm_li_sr3 not created (libvirt)
-f23_rpm_be not created (libvirt)
-f23_ansible not created (libvirt)
-f23_pup_rpm not created (libvirt)
+cent7_li_sr4 not created (virtualbox)
+cent7_be not created (virtualbox)
+cent7_be_sr1 not created (virtualbox)
+cent7_be_sr2 not created (virtualbox)
+cent7_rpm_he_sr4 not created (virtualbox)
+cent7_rpm_li_sr2 not created (virtualbox)
+cent7_rpm_li_sr3 not created (virtualbox)
+cent7_rpm_be not created (virtualbox)
+cent7_rpm_be_sr1 not created (virtualbox)
+cent7_rpm_be_sr2 not created (virtualbox)
+cent7_rpm_ve_latest not created (virtualbox)
+cent7_ansible not created (virtualbox)
+cent7_ansible_latest not created (virtualbox)
+cent7_ansible_path not created (virtualbox)
+cent7_pup_rpm not created (virtualbox)
+cent7_pup_custom_logs not created (virtualbox)
+cent7_pup_enable_l3 not created (virtualbox)
+cent7_pup_tb not created (virtualbox)
+f22_rpm_li not created (virtualbox)
+f22_ansible not created (virtualbox)
+f22_pup_rpm not created (virtualbox)
+f23_rpm_li not created (virtualbox)
+f23_rpm_li_sr1 not created (virtualbox)
+f23_rpm_li_sr2 not created (virtualbox)
+f23_rpm_li_sr3 not created (virtualbox)
+f23_rpm_be not created (virtualbox)
+f23_rpm_be_rel not created (virtualbox)
+f23_rpm_be_latest not created (virtualbox)
+f23_ansible not created (virtualbox)
+f23_pup_rpm not created (virtualbox)
+debian8_ansible_repo not created (virtualbox)
+debian8_ansible_path not created (virtualbox)
+ubuntu16_ansible_repo not created (virtualbox)
+ubuntu16_ansible_path not created (virtualbox)
+ubuntu16_pup_deb not created (virtualbox)
[~/vagrant-opendaylight]$ vagrant up cent7_pup_rpm
# A CentOS 7 VM is created and configured using the ODL Puppet mod's defaults
}
```
-### Install Method
-
-The `install_method` param, and the associated `tarball_url` and `unitfile_url`
-params, are intended for use by developers who need to install a custom-built
-version of OpenDaylight, or for automated build processes that need to consume
-a tarball build artifact.
-
-It's recommended that most people use the default RPM-based install.
-
-If you do need to install from a tarball, simply pass `tarball` as the value
-for `install_method` and optionally pass the URL to your tarball via the
-`tarball_url` param. The default value for `tarball_url` points at
-OpenDaylight's latest release. The `unitfile_url` param points at the
-OpenDaylight systemd .service file used by the RPM and should (very likely)
-not need to be overridden.
-
-```puppet
-class { 'opendaylight':
- install_method => 'tarball',
- tarball_url => '<URL to your custom tarball>',
- unitfile_url => '<URL to your custom unitfile>',
-}
-```
-
### RPM Repo
The `rpm_repo` param can be used to configure which RPM repository
For a full list of OpenDaylight releases and their CBS repos, see the
[OpenDaylight Deployment wiki][19].
-This is only read when `install_method` is `rpm`.
+This is only read for RedHat based operating systems. For Debian based OSs,
+this values is `none`.
+
+### Deb Repo
+
+The `deb_repo` param can be used to configure which Deb repository
+OpenDaylight is installed from.
+
+```puppet
+class { 'opendaylight':
+ deb_repo => 'ppa:odl-team/boron',
+}
+```
+
+The naming convention is same as the naming convention of Launchpad PPA's,
+which is where ODL .debs are hosted. The `ppa:odl-team/boron` example above
+would install OpenDaylight Boron realease from the [odl-team's boron][20] repo.
+
+This is only read for Debian based operating systems. For RedHat based OSs,
+this values is `none`.
### Ports
#### Private classes
- `::opendaylight::params`: Contains default `opendaylight` class param values.
-- `::opendaylight::install`: Installs ODL from an RPM or tarball.
+- `::opendaylight::install`: Installs ODL from an RPM or a Deb.
- `::opendaylight::config`: Manages ODL config, including Karaf features and
REST port.
- `::opendaylight::service`: Starts the OpenDaylight service.
Valid options: A list of Karaf feature names as strings.
-##### `install_method`
-
-Specifies the install method by which to install OpenDaylight.
-
-The RPM install method is less complex, more frequently consumed and
-recommended.
-
-Default: `'rpm'`
-
-Valid options: The strings `'tarball'` or `'rpm'`.
-
##### `odl_rest_port`
Specifies the port for the ODL northbound REST interface to listen on.
Valid options: A valid port number as a string or integer.
+##### `rpm_repo`
+
+OpenDaylight CentOS CBS repo to install RPM from (opendaylight-4-testing,
+opendaylight-40-release, ...).
+
+##### `deb_repo`
+
+OpenDaylight Launchpad PPA repo to install .deb from (ppa:odl-team/boron,
+ppa:odl-team/carbon, ...).
+
##### `log_levels`
Custom OpenDaylight logger verbosity configuration.
Required by: `enable_ha`, `ha_node_ips`
-##### `tarball_url`
-
-Specifies the ODL tarball to use when installing via the tarball install
-method.
-
-Default: `'https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distribution-karaf/0.3.2-Lithium-SR2/distribution-karaf-0.3.2-Lithium-SR2.tar.gz'`
-
-Valid options: A valid URL to an ODL tarball as a string.
-
-##### `unitfile_url`
-
-Specifies the ODL systemd .service file to use when installing via the tarball
-install method.
-
-It's very unlikely that you'll need to override this.
-
-Default: `'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz'`
-
-Valid options: A valid URL to an ODL systemd .service file (archived in a
-tarball) as a string.
-
##### `security_group_mode`
Specifies the mode to use for security groups.
## Limitations
-- Tested on Fedora 22, 23, CentOS 7 and Ubuntu 14.04.
+- Tested on Fedora 22, 23, CentOS 7 and Ubuntu 16.04.
- CentOS 7 is currently the most stable OS option.
-- The RPM install method is likely more reliable than the tarball install
- method.
## Development
[17]: https://github.com/dfarrell07/puppet-opendaylight/commits/master
-[18]: <http://cbs.centos.org/repos/nfv7-opendaylight-40-release/x86_64/os/Packages/> OpenDaylight Beryllium CentOS CBS repo
-[19]: <https://wiki.opendaylight.org/view/Deployment#RPM> OpenDaylight RPMs and their repos
+[18]: <http://cbs.centos.org/repos/nfv7-opendaylight-40-release/x86_64/os/Packages/> "OpenDaylight Beryllium CentOS CBS repo"
+
+[19]: <https://wiki.opendaylight.org/view/Deployment#RPM> "OpenDaylight RPMs and their repos"
+
+[20]: https://launchpad.net/~odl-team/+archive/ubuntu/boron
sh "RS_SET=centos-7-docker INSTALL_METHOD=rpm RPM_REPO='opendaylight-5-release' bundle exec rake beaker"
end
+# Ubuntu VMs
+
+desc "Beaker tests against Ubuntu 16.04 VM with Boron release Deb"
+task :ubuntu_5rel_vm do
+ sh "RS_SET=ubuntu-16 INSTALL_METHOD=deb DEB_REPO='ppa:odl-team/boron' bundle exec rake beaker"
+end
+
+# Ubuntu Containers
+
+desc "Beaker tests against Ubuntu 16.04 Container with Boron release Deb"
+task :ubuntu_5rel_dock do
+ sh "RS_SET=ubuntu-16-docker INSTALL_METHOD=deb DEB_REPO='ppa:odl-team/boron' bundle exec rake beaker"
+end
+
+
# Multi-test helpers
desc "Run syntax, lint, and spec tests."
task :acceptance_vm => [
:test,
:cent_5rel_vm,
+ :ubuntu_5rel_vm,
:cent_5test_vm,
:cent_6test_vm,
]
task :acceptance_dock => [
:test,
:cent_5rel_dock,
+ :ubuntu_5rel_dock,
:cent_5test_dock,
:cent_6test_dock,
]
# Port for ODL northbound REST interface to listen on.
# [*odl_bind_ip *]
# IP for ODL northbound REST interface to bind to.
-# [*install_method *]
-# How to install OpenDaylight. Current options are "rpm" and "tarball",
-# default is RPM.
# [*rpm_repo*]
# OpenDaylight CentOS CBS repo to install RPM from (opendaylight-4-testing,
# opendaylight-40-release, ...).
-# [*tarball_url*]
-# If installing from a tarball, use this one. Defaults to latest ODL.
-# [*unitfile_url*]
-# OpenDaylight .service file to use for tarball installs. Defaults to one
-# used by ODL RPM.
+# [*deb_repo*]
+# OpenDaylight Launchpad PPA repo to install .deb from (ppa:odl-team/boron,
+# ppa:odl-team/carbon, ...).
# [*log_levels*]
# Custom OpenDaylight logger verbosity configuration (TRACE, DEBUG, INFO, WARN, ERROR).
# [*enable_ha*]
$extra_features = $::opendaylight::params::extra_features,
$odl_rest_port = $::opendaylight::params::odl_rest_port,
$odl_bind_ip = $::opendaylight::params::odl_bind_ip,
- $install_method = $::opendaylight::params::install_method,
$rpm_repo = $::opendaylight::params::rpm_repo,
- $tarball_url = $::opendaylight::params::tarball_url,
- $unitfile_url = $::opendaylight::params::unitfile_url,
+ $deb_repo = $::opendaylight::params::deb_repo,
$log_levels = $::opendaylight::params::log_levels,
$enable_ha = $::opendaylight::params::enable_ha,
$ha_node_ips = $::opendaylight::params::ha_node_ips,
}
}
ubuntu: {
- if $::operatingsystemmajrelease != '14.04' {
- # Only tested on 14.04
- fail("Unsupported OS: ${::operatingsystem} ${::operatingsystemmajrelease}")
+ if $::operatingsystemrelease < '16.04' {
+ # Only tested on 16.04
+ fail("Unsupported OS: ${::operatingsystem} ${::operatingsystemrelease}")
}
}
default: {
#
# Manages the installation of OpenDaylight.
#
-# There are two install methods: RPM-based and tarball-based. The resulting
-# system state should be functionally equivalent, but we have to do more
-# work here for the tarball method (would normally be handled by the RPM).
+# There are two install methods: RPM-based and deb-based. The resulting
+# system state should be functionally equivalent.
#
class opendaylight::install {
- if $opendaylight::install_method == 'rpm' {
+ if $::osfamily == 'RedHat' {
# Add OpenDaylight's Yum repository
yumrepo { $opendaylight::rpm_repo:
# 'ensure' isn't supported with Puppet <3.5
path => '/bin'
}
}
- elsif $opendaylight::install_method == 'tarball' {
- # Install Java 7
- $package = $::osfamily ? {
- 'RedHat' => 'java-1.7.0-openjdk',
- 'Debian' => 'openjdk-7-jdk',
- }
- class { 'java':
- # NB: ODL is currently in the process of moving to Java 8
- package => $package,
- }
- # Create and configure the odl user
- user { 'odl':
- ensure => present,
- # Must be a valid dir for the auto-creation of some files
- home => '/opt/opendaylight/',
- # The odl user should, at the minimum, be a member of the odl group
- membership => 'minimum',
- groups => 'odl',
- # The odl user's home dir should exist before the user is created
- # The odl group, to which the odl user will belong, should exist
- require => [Archive['opendaylight'], Group['odl']],
- # The odl user will own this dir, user should exist before we set owner
- before => File['/opt/opendaylight/'],
- }
+ elsif $::osfamily == 'Debian'{
- # Create and configure the odl group
- group { 'odl':
- ensure => present,
- # The odl user will be a member of this group, create it first
- # The odl user will own ODL's dir, so should exist before owner set
- before => [File['/opt/opendaylight/'], User['odl']],
- }
+ include apt
- # Download and extract the ODL tarball
- archive { 'opendaylight':
- ensure => present,
- # URL from which ODL's tarball can be downloaded
- url => $opendaylight::tarball_url,
- # Will end up installing /opt/opendaylight/
- target => '/opt/opendaylight/',
- # ODL doesn't provide a checksum in the expected path, would fail
- checksum => false,
- # This discards top-level dir of extracted tarball
- # Required to get proper /opt/opendaylight/ path
- strip_components => 1,
- root_dir => '.',
- # Default timeout is 120s, which may not be enough. See Issue #53:
- # https://github.com/dfarrell07/puppet-opendaylight/issues/53
- timeout => 600,
- # ODL's archive should be dl'd/extracted before we config mode/user/group
- # The odl user will set this to their home dir, should exist before user
- before => [File['/opt/opendaylight/'], User['odl']],
- }
+ # Add ODL ppa repository
+ apt::ppa{ $opendaylight::deb_repo: }
- # Set the user:group owners and mode of ODL dir
- file { '/opt/opendaylight/':
- # ensure=>dir and recurse=>true are required for managing recursively
- ensure => 'directory',
- recurse => true,
- # Set user:group owners of ODL dir
- owner => 'odl',
- group => 'odl',
- # The ODL archive we're modifying should exist
- # Since ODL's dir is owned by odl:odl, that user:group should exist
- require => [Archive['opendaylight'], Group['odl'], User['odl']],
+ # Install Opendaylight .deb pkg
+ package { 'opendaylight':
+ ensure => present,
+ require => Apt::Ppa[$opendaylight::deb_repo],
}
- # Systemd vs upstart config depends on OS family
- if ( $::osfamily == 'RedHat' ) {
- # Download ODL systemd .service file and put in right location
- archive { 'opendaylight-systemd':
- ensure => present,
- url => $opendaylight::unitfile_url,
- # Will end up installing /usr/lib/systemd/system/opendaylight.service
- target => '/usr/lib/systemd/system/',
- # Required by archive mod for correct exec `creates` param
- root_dir => 'opendaylight.service',
- # ODL doesn't provide a checksum in the expected path, would fail
- checksum => false,
- # This discards top-level dir of extracted tarball
- # Required to get proper /opt/opendaylight-<version> path
- strip_components => 1,
- # May end up with an HTML redirect output in a text file without this
- # Note that the curl'd down file would still have a .tar.gz name
- follow_redirects => true,
- # Should exist before we try to set its user/group/mode
- before => File['/usr/lib/systemd/system/opendaylight.service'],
- }
-
- # Set the user:group owners and mode of ODL's systemd .service file
- file { '/usr/lib/systemd/system/opendaylight.service':
- # It should be a normal file
- ensure => 'file',
- # Set user:group owners of ODL systemd .service file
- owner => 'root',
- group => 'root',
- # Set mode of ODL systemd .service file
- mode => '0644',
- # Should happen after the ODL systemd .service file has been extracted
- require => Archive['opendaylight-systemd'],
- }
- }
- elsif ( $::osfamily == 'Debian' ) {
- file { '/etc/init/opendaylight.conf':
- # It should be a normal file
- ensure => 'file',
- # Set user:group owners of ODL upstart file
- # NB: Unverfied, not sure if this is correct for upstart
- owner => 'root',
- group => 'root',
- # Set mode of ODL upstart file
- # NB: Unverfied, not sure if this is correct for upstart
- mode => '0644',
- # Use Puppet URL for Travis. File stored in <mod name>/files/
- source => 'puppet:///modules/opendaylight/upstart.odl.conf'
- }
- }
- else {
- fail("Unsupported OS family: ${::osfamily}")
- }
+ Apt::Ppa[$opendaylight::deb_repo] -> Package['opendaylight']
}
else {
- fail("Unknown install method: ${opendaylight::install_method}")
+ fail("Unknown operating system method: ${::osfamily}")
}
}
$extra_features = []
$odl_rest_port = '8080'
$odl_bind_ip = '0.0.0.0'
- $install_method = 'rpm'
$rpm_repo = 'opendaylight-5-testing'
- $tarball_url = ''
- $unitfile_url = 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz'
+ $deb_repo = 'ppa:odl-team/boron'
$log_levels = {}
$enable_ha = false
$ha_node_ips = []
install_odl
# Run checks specific to install type, via env var passed from Rakefile
- if ENV['INSTALL_METHOD'] == 'tarball'
- # Call specialized helper fn for tarball-type install validations
- tarball_validations
- else
+ if :osfamily == 'RedHat'
# Call specialized helper fn for RPM-type install validations
rpm_validations
+ elsif :osfamily == 'Debian'
+ # Call specialized helper fn for Deb-type install validations
+ deb_validations
end
# Use helper fn to run generic validations
--- /dev/null
+HOSTS:
+ ubuntu-16-docker:
+ roles:
+ - master
+ platform: ubuntu-1604-x86_64
+ image: ubuntu:16.04
+ hypervisor: docker
+ docker_image_commands:
+ - 'apt-get install -y software-properties-common'
+ docker_cmd: '["/sbin/init"]'
+
+CONFIG:
+ log_level: verbose
+ type: foss
--- /dev/null
+---
+HOSTS:
+ ubuntu-16:
+ roles:
+ - master
+ platform: ubuntu-1604-x86_64
+ box: puphpet/ubuntu1604-x64
+ box_url: https://atlas.hashicorp.com/puphpet/boxes/ubuntu1604-x64
+ hypervisor: vagrant
+CONFIG:
+ log_level: verbose
+ type: foss
describe 'OS family Debian' do
osfamily = 'Debian'
- # All tests for Ubuntu 14.04
+ # All tests for Ubuntu 16.04
describe 'Ubuntu' do
operatingsystem = 'Ubuntu'
# All tests for supported versions of Ubuntu
- ['14.04'].each do |operatingsystemmajrelease|
- context "#{operatingsystemmajrelease}" do
+ ['16.04'].each do |operatingsystemrelease|
+ context "#{operatingsystemrelease}" do
let(:facts) {{
:osfamily => osfamily,
:operatingsystem => operatingsystem,
- :operatingsystemmajrelease => operatingsystemmajrelease,
- # TODO: Do more elegantly. Java mod uses codenames to ID version.
- :lsbdistcodename => 'trusty',
- :architecture => 'x86_64',
+ :operatingsystemrelease => operatingsystemrelease,
+ :lsbdistid => operatingsystem,
+ :lsbdistrelease => operatingsystemrelease,
+ :lsbdistcodename => 'xenial',
+ :puppetversion => '4.9.0',
:path => ['/usr/local/bin', '/usr/bin', '/bin'],
}}
- # NB: Only tarball installs are supported for Debian family OSs
- let(:params) {{
- :install_method => 'tarball',
- }}
-
# Run shared tests applicable to all supported OSs
# Note that this function is defined in spec_helper
generic_tests
- # Run test that specialize in checking tarball-based installs
- # NB: Only testing defaults here, specialized tarball tests elsewhere
- # Passing osfamily required to do upstart vs systemd (default) checks
+ # Run test that specialize in checking deb-based installs
+ # NB: Passing osfamily required to do upstart vs systemd (default) checks
# Note that this function is defined in spec_helper
- tarball_install_tests(osfamily: osfamily)
+ deb_install_tests(osfamily: osfamily)
# Run test that specialize in checking Karaf feature installs
# NB: Only testing defaults here, specialized Karaf tests elsewhere
end
# All tests for unsupported versions of Ubuntu
- ['12.04', '15.10'].each do |operatingsystemmajrelease|
- context "#{operatingsystemmajrelease}" do
+ ['12.04', '14.04', '15.10'].each do |operatingsystemrelease|
+ context "#{operatingsystemrelease}" do
let(:facts) {{
:osfamily => osfamily,
:operatingsystem => operatingsystem,
- :operatingsystemmajrelease => operatingsystemmajrelease,
+ :operatingsystemrelease => operatingsystemrelease,
+ :lsbdistid => operatingsystem,
+ :lsbdistrelease => operatingsystemrelease,
+ :lsbdistcodename => 'xenial',
+ :puppetversion => '4.9.0',
}}
# Run shared tests applicable to all unsupported OSs
# Note that this function is defined in spec_helper
- expected_msg = "Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}"
+ expected_msg = "Unsupported OS: #{operatingsystem} #{operatingsystemrelease}"
unsupported_os_tests(expected_msg: expected_msg)
end
end
# All install method tests
describe 'install method tests' do
- # Non-OS-type tests assume CentOS 7
- # See issue #43 for reasoning:
- # https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
- osfamily = 'RedHat'
- operatingsystem = 'CentOS'
- operatingsystemrelease = '7.0'
- operatingsystemmajrelease = '7'
# All tests for RPM install method
describe 'RPM' do
+ # Non-OS-type tests assume CentOS 7
+ # See issue #43 for reasoning:
+ # https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
+ osfamily = 'RedHat'
+ operatingsystem = 'CentOS'
+ operatingsystemrelease = '7.0'
+ operatingsystemmajrelease = '7'
+
context 'installing default RPM' do
let(:facts) {{
:osfamily => osfamily,
:operatingsystemmajrelease => operatingsystemmajrelease,
}}
- let(:params) {{
- :install_method => 'rpm',
- }}
-
# Run shared tests applicable to all supported OSs
# Note that this function is defined in spec_helper
generic_tests
}}
let(:params) {{
- :install_method => 'rpm',
:rpm_repo => rpm_repo,
}}
end
end
- # All tests for tarball install method
- describe 'tarball' do
- describe 'using default tarball_url' do
- context 'using default unitfile_url' do
- let(:facts) {{
- :osfamily => osfamily,
- :operatingsystem => operatingsystem,
- :operatingsystemrelease => operatingsystemrelease,
- :operatingsystemmajrelease => operatingsystemmajrelease,
- :architecture => 'x86_64',
- :path => ['/usr/local/bin', '/usr/bin', '/bin'],
- }}
-
- let(:params) {{
- :install_method => 'tarball',
- }}
-
- # Run shared tests applicable to all supported OSs
- # Note that this function is defined in spec_helper
- generic_tests
-
- # Run test that specialize in checking tarball-based installs
- # Note that this function is defined in spec_helper
- tarball_install_tests
- end
+ # All tests for Deb install method
+ describe 'Deb' do
+ osfamily = 'Debian'
+ operatingsystem = 'Ubuntu'
+ operatingsystemrelease = '16.04'
+ operatingsystemmajrelease = '16'
+ lsbdistcodename = 'xenial'
+
+ context 'installing Deb' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemrelease => operatingsystemrelease,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ :lsbdistid => operatingsystem,
+ :lsbdistrelease => operatingsystemrelease,
+ :lsbmajdistrelease => operatingsystemmajrelease,
+ :lsbdistcodename => lsbdistcodename,
+ :puppetversion => Puppet.version,
+ }}
- context 'overriding default unitfile_url' do
- # Doesn't matter if this is valid, just that it honors what we pass
- unitfile_url = 'fake_unitfile'
- let(:facts) {{
- :osfamily => osfamily,
- :operatingsystem => operatingsystem,
- :operatingsystemrelease => operatingsystemrelease,
- :operatingsystemmajrelease => operatingsystemmajrelease,
- :architecture => 'x86_64',
- :path => ['/usr/local/bin', '/usr/bin', '/bin'],
- }}
-
- let(:params) {{
- :install_method => 'tarball',
- :unitfile_url => unitfile_url,
- }}
-
- # Run shared tests applicable to all supported OSs
- # Note that this function is defined in spec_helper
- generic_tests
-
- # Run test that specialize in checking tarball-based installs
- # Note that this function is defined in spec_helper
- tarball_install_tests(unitfile_url: unitfile_url)
- end
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test that specialize in checking RPM-based installs
+ # Note that this function is defined in spec_helper
+ deb_install_tests
end
- describe 'overriding default tarball_url' do
- # Doesn't matter if this is valid, just that it honors what we pass
- tarball_url = 'fake_tarball'
- context 'using default unitfile_url' do
- unitfile_url = 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz'
- let(:facts) {{
- :osfamily => osfamily,
- :operatingsystem => operatingsystem,
- :operatingsystemrelease => operatingsystemrelease,
- :operatingsystemmajrelease => operatingsystemmajrelease,
- :architecture => 'x86_64',
- :path => ['/usr/local/bin', '/usr/bin', '/bin'],
- }}
-
- let(:params) {{
- :install_method => 'tarball',
- :tarball_url => tarball_url,
- }}
-
- # Run shared tests applicable to all supported OSs
- # Note that this function is defined in spec_helper
- generic_tests
-
- # Run test that specialize in checking tarball-based installs
- # Note that this function is defined in spec_helper
- tarball_install_tests(tarball_url: tarball_url)
- end
+ context 'installing Boron Deb' do
+ deb_repo = 'ppa:odl-team/boron'
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemrelease => operatingsystemrelease,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ :lsbdistid => operatingsystem,
+ :lsbdistrelease => operatingsystemrelease,
+ :lsbmajdistrelease => operatingsystemmajrelease,
+ :lsbdistcodename => lsbdistcodename,
+ :puppetversion => Puppet.version,
+ }}
- context 'overriding default unitfile_url' do
- # Doesn't matter if this is valid, just that it honors what we pass
- unitfile_url = 'fake_unitfile'
- let(:facts) {{
- :osfamily => osfamily,
- :operatingsystem => operatingsystem,
- :operatingsystemrelease => operatingsystemrelease,
- :operatingsystemmajrelease => operatingsystemmajrelease,
- :architecture => 'x86_64',
- :path => ['/usr/local/bin', '/usr/bin', '/bin'],
- }}
-
- let(:params) {{
- :install_method => 'tarball',
- :tarball_url => tarball_url,
- :unitfile_url => unitfile_url,
- }}
-
- # Run shared tests applicable to all supported OSs
- # Note that this function is defined in spec_helper
- generic_tests
-
- # Run test that specialize in checking tarball-based installs
- # Note that this function is defined in spec_helper
- tarball_install_tests(tarball_url: tarball_url, unitfile_url: unitfile_url)
- end
+ let(:params) {{
+ :deb_repo => deb_repo,
+ }}
+
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test that specialize in checking RPM-based installs
+ # Note that this function is defined in spec_helper
+ deb_install_tests(deb_repo: deb_repo)
end
end
+
end
+
# Security Group Tests
describe 'security group tests' do
# Non-OS-type tests assume CentOS 7
end
end
-def tarball_install_tests(options = {})
- # Extract params
- # NB: These default values should be the same as ones in opendaylight::params
- # TODO: Remove this possible source of bugs^^
- tarball_url = options.fetch(:tarball_url, '')
- unitfile_url = options.fetch(:unitfile_url, 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz')
- osfamily = options.fetch(:osfamily, 'RedHat')
- rpm_repo = options.fetch(:rpm_repo, 'opendaylight-5-testing')
-
- # Confirm presence of tarball-related resources
- it { should contain_archive('opendaylight') }
- it { should contain_class('java') }
- it { should contain_file('/opt/opendaylight/') }
- it { should contain_user('odl') }
- it { should contain_group('odl') }
-
- # Confirm relationships between tarball-related resources
- it { should contain_archive('opendaylight').that_comes_before('File[/opt/opendaylight/]') }
- it { should contain_archive('opendaylight').that_comes_before('User[odl]') }
- it { should contain_file('/opt/opendaylight/').that_requires('Archive[opendaylight]') }
- it { should contain_file('/opt/opendaylight/').that_requires('Group[odl]') }
- it { should contain_file('/opt/opendaylight/').that_requires('User[odl]') }
- it { should contain_user('odl').that_comes_before('File[/opt/opendaylight/]') }
- it { should contain_user('odl').that_requires('Archive[opendaylight]') }
- it { should contain_user('odl').that_requires('Group[odl]') }
- it { should contain_group('odl').that_comes_before('File[/opt/opendaylight/]') }
- it { should contain_group('odl').that_comes_before('User[odl]') }
-
- # Confirm properties of tarball-related resources
- # NB: These hashes don't work with Ruby 1.8.7, but we
- # don't support 1.8.7 so that's okay. See issue #36.
- it {
- should contain_archive('opendaylight').with(
- 'ensure' => 'present',
- 'url' => tarball_url,
- 'target' => '/opt/opendaylight/',
- 'checksum' => false,
- 'strip_components' => 1,
- 'timeout' => 600,
- )
- }
- it {
- should contain_file('/opt/opendaylight/').with(
- 'ensure' => 'directory',
- 'recurse' => true,
- 'owner' => 'odl',
- 'group' => 'odl',
- )
- }
- it {
- should contain_user('odl').with(
- 'name' => 'odl',
- 'ensure' => 'present',
- 'home' => '/opt/opendaylight/',
- 'membership' => 'minimum',
- 'groups' => 'odl',
- )
- }
- it {
- should contain_group('odl').with(
- 'name' => 'odl',
- 'ensure' => 'present',
- )
- }
-
- # OS-specific validations
- case osfamily
- when 'RedHat'
- # Validations specific to Red Hat family OSs (RHEL/CentOS/Fedora)
- it { should contain_archive('opendaylight-systemd') }
- it { should contain_file('/usr/lib/systemd/system/opendaylight.service') }
- it { should contain_archive('opendaylight-systemd').that_comes_before('File[/usr/lib/systemd/system/opendaylight.service]') }
- it { should contain_file('/usr/lib/systemd/system/opendaylight.service').that_requires('Archive[opendaylight-systemd]') }
-
- # NB: These hashes don't work with Ruby 1.8.7, but we
- # don't support 1.8.7 so that's okay. See issue #36.
- it {
- should contain_package('java').with(
- 'name' => 'java-1.7.0-openjdk',
- )
- }
- it {
- should contain_archive('opendaylight-systemd').with(
- 'ensure' => 'present',
- 'url' => unitfile_url,
- 'target' => '/usr/lib/systemd/system/',
- 'root_dir' => 'opendaylight.service',
- 'checksum' => false,
- 'strip_components' => 1,
- 'follow_redirects' => true,
- )
- }
- it {
- should contain_file('/usr/lib/systemd/system/opendaylight.service').with(
- 'ensure' => 'file',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- )
- }
- when 'Debian'
- # Validations specific to Debain family OSs (Ubuntu)
- it {
- should contain_package('java').with(
- 'name' => 'openjdk-7-jdk',
- )
- }
- it {
- should contain_file('/etc/init/opendaylight.conf').with(
- 'ensure' => 'file',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- )
- }
- expected_msg = 'Debian has limited support, is less stable, less tested.'
- it {
- expect {
- # This could be any check, most (all?) will raise warning
- should contain_file('/etc/init/opendaylight.conf').to(
- raise_warning(Puppet::Warning, /#{expected_msg}/)
- )
- }
- }
- else
- fail("Unexpected osfamily #{osfamily}")
- end
-
- # Verify that there are no unexpected resources from RPM-type installs
- it { should_not contain_yumrepo(rpm_repo) }
- it { should_not contain_package('opendaylight') }
-end
-
def rpm_install_tests(options = {})
# Extract params
rpm_repo = options.fetch(:rpm_repo, 'opendaylight-5-testing')
}
end
+def deb_install_tests(options = {})
+ # Extract params
+ deb_repo = options.fetch(:deb_repo, 'ppa:odl-team/boron')
+
+ # Confirm the presence of Deb-related resources
+ it { should contain_apt__ppa(deb_repo) }
+ it { should contain_package('opendaylight') }
+
+ # Confirm relationships between Deb-related resources
+ it { should contain_package('opendaylight').that_requires("Apt::Ppa[#{deb_repo}]") }
+ it { should contain_apt__ppa(deb_repo).that_comes_before('Package[opendaylight]') }
+
+ # Confirm presence of Deb-related resources
+ it {
+ should contain_package('opendaylight').with(
+ 'ensure' => 'present',
+ )
+ }
+end
+
# Shared tests for unsupported OSs
def unsupported_os_tests(options = {})
# Extract params
# Install Puppet
if host.is_pe?
install_pe
+ elsif host.name == "ubuntu-16-docker" || host.name == "ubuntu-16"
+ install_puppet_agent_on(host, puppet_collection: "pc1")
else
install_puppet
end
hosts.each do |host|
# Install stdlib, a dependency of the odl mod
on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0] }
- # Install archive, a dependency of the odl mod use for tarball-type installs
- on host, puppet('module', 'install', 'camptocamp-archive'), { :acceptable_exit_codes => [0] }
- # Install Java Puppet mod, a dependency of the tarball install method
- on host, puppet('module', 'install', 'puppetlabs-java'), { :acceptable_exit_codes => [0] }
+ # Install apt, a dependency of the deb install method
+ on host, puppet('module', 'install', 'puppetlabs-apt'), { :acceptable_exit_codes => [0] }
end
end
end
# Changing the installed version of ODL via `puppet apply` is not supported
# by puppet-odl, so it's not possible to vary these params in the same
# Beaker test run. Do a different run passing different env vars.
- install_method = ENV['INSTALL_METHOD']
rpm_repo = ENV['RPM_REPO']
+ deb_repo = ENV['DEB_REPO']
+
+ if rpm_repo == ''
+ rpm_repo = 'none'
+ elsif deb_repo == ''
+ deb_repo = 'none'
+ end
# NB: These param defaults should match the ones used by the opendaylight
# class, which are defined in opendaylight::params
it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'opendaylight':
- install_method => #{install_method},
- rpm_repo => #{rpm_repo},
+ rpm_repo => '#{rpm_repo}',
+ deb_repo => '#{deb_repo}',
default_features => #{default_features},
extra_features => #{extra_features},
odl_rest_port=> #{odl_rest_port},
describe service('opendaylight') do
it { should be_enabled }
it { should be_enabled.with_level(3) }
- it { should be_running }
+ it { should be_running.under('systemd') }
end
- # Creation handled by RPM, or Puppet during tarball installs
+ # Creation handled by RPM or Deb
describe user('odl') do
it { should exist }
it { should belong_to_group 'odl' }
it { should have_home_directory '/opt/opendaylight' }
end
- # Creation handled by RPM, or Puppet during tarball installs
+ # Creation handled by RPM or Deb
describe group('odl') do
it { should exist }
end
describe package('java-1.8.0-openjdk') do
it { should be_installed }
end
- elsif ['ubuntu-1404', 'ubuntu-1404-docker'].include? ENV['RS_SET']
- # Ubuntu-specific validations
- # Verify ODL Upstart config file
- describe file('/etc/init/opendaylight.conf') do
+ # Ubuntu 16.04 specific validation
+ elsif ['ubuntu-16', 'ubuntu-16-docker'].include? ENV['RS_SET']
+
+ # Verify ODL systemd .service file
+ describe file('/lib/systemd/system/opendaylight.service') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode '644' }
end
- # Java 7 should be installed
- describe package('openjdk-7-jdk') do
+ # Java 8 should be installed
+ describe package('openjdk-8-jre-headless') do
it { should be_installed }
end
+
else
fail("Unexpected RS_SET (host OS): #{ENV['RS_SET']}")
end
end
end
-# Shared function that handles validations specific to tarball-type installs
-def tarball_validations()
- rpm_repo = ENV['RPM_REPO']
-
- describe package('opendaylight') do
- it { should_not be_installed }
+# Shared function that handles validations specific to Deb-type installs
+def deb_validations()
+ deb_repo = ENV['DEB_REPO']
+ # Check ppa
+ # Docs: http://serverspec.org/resource_types.html#ppa
+ describe ppa(deb_repo) do
+ it { should exist }
+ it { should be_enabled }
end
- # Repo checks break (not fail) when yum doesn't make sense (Ubuntu)
- if ['centos-7', 'fedora-22', 'fedora-23', 'fedora-23-docker'].include? ENV['RS_SET']
- describe yumrepo(rpm_repo) do
- it { should_not exist }
- it { should_not be_enabled }
- end
+ describe package('opendaylight') do
+ it { should be_installed }
end
end