Skip to content

Commit

Permalink
Make repo_location usable
Browse files Browse the repository at this point in the history
Before this commit, repo_location was usable because it wasn't handle
within zabbix::repo.

Fixes voxpupuli#537.
  • Loading branch information
baurmatt committed Sep 17, 2018
1 parent 214444c commit 062437e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
$default_vhost = false
$manage_firewall = false
$manage_apt = true
$repo_location = ''
$repo_location = undef
$manage_resources = false
$manage_vhost = true
$database_path = '/usr/sbin'
Expand Down
14 changes: 8 additions & 6 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# [*zabbix_version*]
# This is the zabbix version.
#
# [*repo_location*]
# A custom repo location (e.g. your own mirror)
#
# === Authors
#
Expand All @@ -26,10 +28,10 @@
# Copyright 2014 Werner Dijkerman
#
class zabbix::repo (
$manage_repo = $zabbix::params::manage_repo,
$manage_apt = $zabbix::params::manage_apt,
$repo_location = $zabbix::params::repo_location,
$zabbix_version = $zabbix::params::zabbix_version,
Boolean $manage_repo = $zabbix::params::manage_repo,
Boolean $manage_apt = $zabbix::params::manage_apt,
Optional[Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl]] $repo_location = $zabbix::params::repo_location,
String[1] $zabbix_version = $zabbix::params::zabbix_version,
) inherits zabbix::params {
if ($manage_repo) {
case $facts['os']['name'] {
Expand Down Expand Up @@ -62,7 +64,7 @@
yumrepo { 'zabbix':
name => "Zabbix_${majorrelease}_${facts['os']['architecture']}",
descr => "Zabbix_${majorrelease}_${facts['os']['architecture']}",
baseurl => "https://repo.zabbix.com/zabbix/${zabbix_version}/rhel/${majorrelease}/\$basearch/",
baseurl => pick($repo_location, "https://repo.zabbix.com/zabbix/${zabbix_version}/rhel/${majorrelease}/\$basearch/"),
gpgcheck => '1',
gpgkey => $gpgkey_zabbix,
priority => '1',
Expand Down Expand Up @@ -116,7 +118,7 @@
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
}
apt::source { 'zabbix':
location => "http://repo.zabbix.com/zabbix/${zabbix_version}/${operatingsystem}/",
location => pick($repo_location, "http://repo.zabbix.com/zabbix/${zabbix_version}/${operatingsystem}/"),
repos => 'main',
release => $releasename,
require => [
Expand Down
20 changes: 20 additions & 0 deletions spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
it { is_expected.to contain_class('zabbix::params') }
it { is_expected.to contain_class('zabbix::repo') }

context 'when repo_location is "https://example.com/foo"' do
let :params do
{
repo_location: 'https://example.com/foo'
}
end

it { is_expected.to contain_apt__source('zabbix').with_location('https://example.com/foo') }
end

case facts[:os]['release']['major']
when '6'
context 'on Debian 6 and Zabbix 2.0' do
Expand Down Expand Up @@ -138,6 +148,16 @@
it { is_expected.to contain_class('zabbix::repo') }
# rubocop:enable RSpec/RepeatedExample

context 'when repo_location is "https://example.com/foo"' do
let :params do
{
repo_location: 'https://example.com/foo'
}
end

it { is_expected.to contain_yumrepo('zabbix').with_baseurl('https://example.com/foo') }
end

case facts[:os]['release']['major']
when '5'
context 'on RedHat 5 and Zabbix 2.0' do
Expand Down

0 comments on commit 062437e

Please sign in to comment.