Skip to content

Commit

Permalink
Adds Collectd CI Package repos
Browse files Browse the repository at this point in the history
* Allows installation of 5.6 version of Collectd, 5.7 or RC (current master branch)
* Refactor repo management behaviour into it's own classes
* Add parameter to specify version from bleeding edge repos from CI
  • Loading branch information
petems committed Dec 19, 2016
1 parent 004c3ad commit 895ca35
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 30 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ collectd::plugin { 'battery': }
where 'battery' is the name of the plugin. Note, this should only be done in the
case of a class for the plugin not existing in this module.

## Repo management

The module will enable a repo by default.

On CentOS that will be EPEL:
* http://rpms.famillecollet.com/rpmphp/zoom.php?rpm=collectd

On Ubuntu that'll be the CollectD PPA:
* https://launchpad.net/~collectd/+archive/ubuntu/collectd-5.5

### CI Packages

Recently, Collectd CI packages are also avaliable from the CI repo

More information is avaliable here:
* https://github.com/collectd/collectd-ci

You can choose the CI repo with the `$ci_package_repo` parameter.

`$ci_package_repo` has to match '5.4', '5.5', '5.6', '5.7' or 'master' (RC for next release) as
these are the current branches being built in the Collectd CI.

## Configurable Plugins

Parameters will vary widely between plugins. See the collectd
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
$internal_stats = $collectd::params::internal_stats,
$manage_package = $collectd::params::manage_package,
$manage_repo = $collectd::params::manage_repo,
$ci_package_repo = $collectd::params::ci_package_repo,
$manage_service = $collectd::params::manage_service,
$minimum_version = $collectd::params::minimum_version,
$package_ensure = $collectd::params::package_ensure,
Expand Down Expand Up @@ -39,13 +40,18 @@
package_install_options => $package_install_options,
}

class { '::collectd::repo': }

class { '::collectd::config': }

class { '::collectd::service': }

anchor { 'collectd::begin': }
anchor { 'collectd::end': }

Class['::collectd::repo'] ~>
Class['::collectd::install']

Anchor['collectd::begin'] ->
Class['collectd::install'] ->
Class['collectd::config'] ~>
Expand Down
26 changes: 0 additions & 26 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,6 @@
validate_array($package_install_options)
}

if $::collectd::manage_repo {
if $::osfamily == 'RedHat' {
if !defined(Yum::Install['epel-release']) {
yum::install { 'epel-release':
ensure => 'present',
source => "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${::operatingsystemmajrelease}.noarch.rpm",
}
}
Package <| title == $package_name |> {
require => Yum::Install['epel-release']
}
} elsif $::operatingsystemmajrelease =~ /('12.04'|'14.04'|'16.04')/ {
apt::source { 'ppa_collectd':
location => 'http://ppa.launchpad.net/collectd/collectd-5.5/ubuntu',
repos => 'main',
key => {
'id' => '7543C08D555DC473B9270ACDAF7ECBB3476ACEB3',
'server' => 'keyserver.ubuntu.com',
},
}
Package <| title == $package_name |> {
require => Apt::Source['ppa_collectd']
}
}
}

if $manage_package {
package { $package_name:
ensure => $package_ensure,
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$manage_service = true
$package_install_options = undef
$plugin_conf_dir_mode = '0750'
$ci_package_repo = undef

case getvar('::kernel') {
'OpenBSD': { $has_wordexp = false }
Expand Down
20 changes: 20 additions & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# collectd::repo
# Handle package repo configuration
class collectd::repo {

if $collectd::manage_repo {
if $::collectd::ci_package_repo != undef {
validate_re($::collectd::ci_package_repo, [ '^5.4', '^5.5', '^5.6', '5.7', '^master' ], "ci_package_repo has to match '5.4', '5.5', '5.6', '5.7' or 'master' (RC for next release), got: ${::collectd::ci_package_repo}")
}

$osfamily_downcase = downcase($::osfamily)

if defined("::collectd::repo::${osfamily_downcase}") {
include "::collectd::repo::${osfamily_downcase}"
} else {
notify{"You have asked to manage_repo on a system that doesn't have a repo class specified: ${::osfamily}":}
}
}

}

31 changes: 31 additions & 0 deletions manifests/repo/debian.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class collectd::repo::debian {

contain ::apt

if $::collectd::ci_package_repo {

apt::source { 'collectd-ci':
location => 'https://pkg.ci.collectd.org/deb/',
repos => "collectd-${$::collectd::ci_package_repo}",
key => {
'id' => 'F806817DC3F5EA417F9FA2963994D24FB8543576',
'server' => 'pgp.mit.edu',
},
}
} else {
if $::operatingsystem == 'Debian' {
warning('Youre trying to use the Ubuntu PPA on a Debian Server, which may cause errors')
warning('We recomend you use the $ci_package_repo parameter if you with to use an upstream repo on Debian')
} else {
apt::source { 'ppa_collectd':
location => 'http://ppa.launchpad.net/collectd/collectd-5.5/ubuntu',
repos => 'main',
key => {
'id' => '7543C08D555DC473B9270ACDAF7ECBB3476ACEB3',
'server' => 'keyserver.ubuntu.com',
},
}
}
}

}
27 changes: 27 additions & 0 deletions manifests/repo/redhat.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class collectd::repo::redhat {

if $::collectd::ci_package_repo {

yumrepo { 'collectd-ci':
ensure => present,
enabled => '1',
baseurl => "https://pkg.ci.collectd.org/rpm/collectd-${::collectd::ci_package_repo}/epel-${::operatingsystemmajrelease}-${::architecture}",
gpgkey => 'https://pkg.ci.collectd.org/pubkey.asc',
}

} else {

# TODO: Replace this with EPEL module requirement in Major version bump

if !defined(Yum::Install['epel-release']) {
yum::install { 'epel-release':
ensure => 'present',
source => "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${::operatingsystemmajrelease}.noarch.rpm",
before => Package[$::collectd::package_name],
}
}


}

}
31 changes: 28 additions & 3 deletions spec/classes/collectd_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,34 @@
end

context 'when manage_repo is true' do
let(:params) { { manage_repo: true } }
if facts[:osfamily] == 'RedHat'
it { is_expected.to contain_yum__install('epel-release') }
context 'and ci_package_repo empty' do
let(:params) { { manage_repo: true } }
if facts[:osfamily] == 'RedHat'
it { is_expected.to contain_yum__install('epel-release') }
end
end

context 'and ci_package_repo set to a version' do
let(:params) do
{
manage_repo: true,
ci_package_repo: '5.6'
}
end
if facts[:osfamily] == 'RedHat'
it { is_expected.to contain_yumrepo('collectd-ci').with_gpgkey('https://pkg.ci.collectd.org/pubkey.asc').with_baseurl("https://pkg.ci.collectd.org/rpm/collectd-5.6/epel-#{facts[:operatingsystemmajrelease]}-x86_64") }
end
if facts[:osfamily] == 'Debian'
it do
is_expected.to contain_apt__source('collectd-ci').
with_location('https://pkg.ci.collectd.org/deb/').
with_key(
'id' => 'F806817DC3F5EA417F9FA2963994D24FB8543576',
'server' => 'pgp.mit.edu'
).
with_repos('collectd-5.6')
end
end
end
end

Expand Down
5 changes: 4 additions & 1 deletion spec/default_module_facts.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
---
collectd_version: '5.5.0'
python_dir: '/usr/local/lib/python2.7/dist-packages'
python_dir: '/usr/local/lib/python2.7/dist-packages'
operatingsystem: 'Debian'
lsbdistid: 'Debian'
lsbdistcodename: 'wheezy'

0 comments on commit 895ca35

Please sign in to comment.