-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from mwhahaha/repositories
Allow for disabling repository configuration
- Loading branch information
Showing
8 changed files
with
150 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# == Class: opendaylight::repos | ||
# | ||
# Manages the installation of the OpenDaylight repositories for RedHat and | ||
# Debian | ||
# | ||
# === Parameters | ||
# | ||
# [*deb_repo*] | ||
# The name of the debppa repo to configure. Ignored if on a RHEL based system. | ||
# Defaults to $::opendaylight::deb_repo | ||
# | ||
# [*rpm_repo*] | ||
# The name of the rpm repo to configure. Ignored if on a Debian based system | ||
# Defaults to $::opendaylight::rpm_repo | ||
# | ||
# [*rpm_repo_enabled*] | ||
# Flag to indicate if the the rpm repo should be enabled or disabled. | ||
# Defualts to 1. | ||
# | ||
# [*rpm_repo_gpgcheck*] | ||
# Flag to indicate if the rpm repo should be configured with gpgcheck. | ||
# Defaults to 0. | ||
# | ||
class opendaylight::repos ( | ||
$deb_repo = $::opendaylight::deb_repo, | ||
$rpm_repo = $::opendaylight::rpm_repo, | ||
$rpm_repo_enabled = 1, | ||
$rpm_repo_gpgcheck = 0, | ||
) inherits ::opendaylight { | ||
if $::osfamily == 'RedHat' { | ||
# Add OpenDaylight's Yum repository | ||
yumrepo { $rpm_repo: | ||
# 'ensure' isn't supported with Puppet <3.5 | ||
# Seems to default to present, but docs don't say | ||
# https://docs.puppetlabs.com/references/3.4.0/type.html#yumrepo | ||
# https://docs.puppetlabs.com/references/3.5.0/type.html#yumrepo | ||
baseurl => "http://cbs.centos.org/repos/nfv7-${rpm_repo}/\$basearch/os/", | ||
descr => 'OpenDaylight SDN Controller', | ||
enabled => $rpm_repo_enabled, | ||
# NB: RPM signing is an active TODO, but is not done. We will enable | ||
# this gpgcheck once the RPM supports it. | ||
gpgcheck => $rpm_repo_gpgcheck, | ||
} | ||
} elsif ($::osfamily == 'Debian') { | ||
include ::apt | ||
|
||
# Add ODL ppa repository | ||
apt::ppa{ $deb_repo: } | ||
} else { | ||
fail("Unknown operating system method: ${::osfamily}") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ | |
{ | ||
"operatingsystem": "Ubuntu", | ||
"operatingsystemrelease": [ | ||
"14.04" | ||
"16.04" | ||
] | ||
} | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require 'spec_helper' | ||
|
||
describe 'opendaylight::repos' do | ||
shared_examples_for "opendaylight::repos on Debian" do | ||
context "with defaults" do | ||
it { should contain_class('opendaylight::repos') } | ||
it { should contain_class('apt') } | ||
it { should contain_apt__ppa('ppa:odl-team/boron') } | ||
end | ||
|
||
context "with custom deb_repo" do | ||
let(:params) do | ||
{ :deb_repo => 'ppa:foo/testing' } | ||
end | ||
|
||
it { should contain_apt__ppa('ppa:foo/testing') } | ||
end | ||
end | ||
shared_examples_for "opendaylight::repos on RedHat" do | ||
context "with defaults" do | ||
it { should contain_class('opendaylight::repos') } | ||
it { | ||
should contain_yumrepo('opendaylight-5-testing').with( | ||
:baseurl => 'http://cbs.centos.org/repos/nfv7-opendaylight-5-testing/$basearch/os/', | ||
:enabled => 1, | ||
:gpgcheck => 0, | ||
) | ||
} | ||
end | ||
|
||
context "with custom rpm repo options" do | ||
let(:params) do | ||
{ | ||
:rpm_repo => 'testing', | ||
:rpm_repo_enabled => 0, | ||
:rpm_repo_gpgcheck => 1, | ||
} | ||
end | ||
it { | ||
should contain_yumrepo('testing').with( | ||
:baseurl => 'http://cbs.centos.org/repos/nfv7-testing/$basearch/os/', | ||
:enabled => 0, | ||
:gpgcheck => 1, | ||
) | ||
} | ||
|
||
end | ||
end | ||
|
||
describe "on unsupported os" do | ||
context "when on Solaris" do | ||
let(:facts) do | ||
{:osfamily => 'Solaris', :operatingsystem => 'Solaris'} | ||
end | ||
|
||
|
||
it 'should fail' do | ||
expect { is_expected.to raise_error(Puppet::Error) } | ||
end | ||
end | ||
end | ||
|
||
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
let (:facts) do | ||
facts | ||
end | ||
|
||
it_behaves_like "opendaylight::repos on #{facts[:osfamily]}" | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters