diff --git a/manifests/params.pp b/manifests/params.pp index 56cd6e647..89f12d0f3 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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' diff --git a/manifests/repo.pp b/manifests/repo.pp index e6fe35daf..4fea8fe00 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -14,6 +14,8 @@ # [*zabbix_version*] # This is the zabbix version. # +# [*repo_location*] +# A custom repo location (e.g. your own mirror) # # === Authors # @@ -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, + 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'] { @@ -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', @@ -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 => [ diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index ab0bbe7f9..19e9541b7 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -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 @@ -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