From b38b027011983eb57d7023196ac009d1f5d7e8be Mon Sep 17 00:00:00 2001 From: Elfranne Date: Thu, 17 Jan 2019 16:17:42 +0100 Subject: [PATCH 1/2] add repo_source for custom Debian repo --- manifests/init.pp | 1 + manifests/package/debian.pp | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 657d6d931..dcdaf55a2 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -154,6 +154,7 @@ Boolean $mime_types_preserve_defaults = false, Optional[String] $repo_release = undef, $passenger_package_ensure = 'present', + $repo_source = undef, ### END Package Configuration ### ### START Service Configuation ### diff --git a/manifests/package/debian.pp b/manifests/package/debian.pp index 83036530c..8326d53a3 100644 --- a/manifests/package/debian.pp +++ b/manifests/package/debian.pp @@ -22,6 +22,7 @@ $passenger_package_ensure = $nginx::passenger_package_ensure $manage_repo = $nginx::manage_repo $release = $nginx::repo_release + $repo_source = $nginx::repo_source $distro = downcase($facts['os']['name']) @@ -36,24 +37,27 @@ case $package_source { 'nginx', 'nginx-stable': { + $stable_repo_source = $repo_source ? { undef => "https://nginx.org/packages/${distro}", default => $repo_source } apt::source { 'nginx': - location => "https://nginx.org/packages/${distro}", + location => $stable_repo_source, repos => 'nginx', key => {'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62'}, release => $release, } } 'nginx-mainline': { + $mainline_repo_source = $repo_source ? { undef => "https://nginx.org/packages/mainline/${distro}", default => $repo_source } apt::source { 'nginx': - location => "https://nginx.org/packages/mainline/${distro}", + location => $mainline_repo_source, repos => 'nginx', key => {'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62'}, release => $release, } } 'passenger': { + $passenger_repo_source = $repo_source ? { undef => 'https://oss-binaries.phusionpassenger.com/apt/passenger', default => $repo_source } apt::source { 'nginx': - location => 'https://oss-binaries.phusionpassenger.com/apt/passenger', + location => $passenger_repo_source, repos => 'main', key => {'id' => '16378A33A6EF16762922526E561F9B9CAC40B2F7'}, } From 8b67cbc9e75fa412643b6a914b2ae94f5899bff8 Mon Sep 17 00:00:00 2001 From: Elfranne Date: Fri, 8 Feb 2019 18:04:08 +0100 Subject: [PATCH 2/2] Added test for repo_source and other things from @bastelfreak --- manifests/init.pp | 2 +- manifests/package/debian.pp | 15 ++++++++++++--- metadata.json | 2 +- spec/classes/nginx_spec.rb | 10 ++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index dcdaf55a2..ba60712fb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -154,7 +154,7 @@ Boolean $mime_types_preserve_defaults = false, Optional[String] $repo_release = undef, $passenger_package_ensure = 'present', - $repo_source = undef, + Optional[Stdlib::HTTPUrl] $repo_source = undef, ### END Package Configuration ### ### START Service Configuation ### diff --git a/manifests/package/debian.pp b/manifests/package/debian.pp index 8326d53a3..8f055b97f 100644 --- a/manifests/package/debian.pp +++ b/manifests/package/debian.pp @@ -37,7 +37,10 @@ case $package_source { 'nginx', 'nginx-stable': { - $stable_repo_source = $repo_source ? { undef => "https://nginx.org/packages/${distro}", default => $repo_source } + $stable_repo_source = $repo_source ? { + undef => "https://nginx.org/packages/${distro}", + default => $repo_source, + } apt::source { 'nginx': location => $stable_repo_source, repos => 'nginx', @@ -46,7 +49,10 @@ } } 'nginx-mainline': { - $mainline_repo_source = $repo_source ? { undef => "https://nginx.org/packages/mainline/${distro}", default => $repo_source } + $mainline_repo_source = $repo_source ? { + undef => "https://nginx.org/packages/mainline/${distro}", + default => $repo_source, + } apt::source { 'nginx': location => $mainline_repo_source, repos => 'nginx', @@ -55,7 +61,10 @@ } } 'passenger': { - $passenger_repo_source = $repo_source ? { undef => 'https://oss-binaries.phusionpassenger.com/apt/passenger', default => $repo_source } + $passenger_repo_source = $repo_source ? { + undef => 'https://oss-binaries.phusionpassenger.com/apt/passenger', + default => $repo_source, + } apt::source { 'nginx': location => $passenger_repo_source, repos => 'main', diff --git a/metadata.json b/metadata.json index 7f6616d2a..1f33d6e9c 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 4.25.0 < 6.0.0" + "version_requirement": ">= 5.0.0 < 6.0.0" }, { "name": "puppetlabs/concat", diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 5787819e8..103fdbea4 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -152,6 +152,16 @@ end end + context 'repo_source' do + let(:params) { { repo_source: 'https://example.com/nginx' } } + + it do + is_expected.to contain_apt__source('nginx').with( + 'location' => 'https://example.com/nginx' + ) + end + end + context 'package_source => nginx-mainline' do let(:params) { { package_source: 'nginx-mainline' } }