From db47d346dd8bc0385991e153b3ba835d47c4ba26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Thu, 8 Aug 2019 09:35:03 +0200 Subject: [PATCH 1/3] Add apt::key_options for default apt::key options --- manifests/init.pp | 4 ++++ manifests/key.pp | 2 +- manifests/params.pp | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index d95bbe60b2..b8bc45b59d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,6 +9,9 @@ # Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or # hkp://). # +# @param key_options +# Specifies the default options for apt::key resources. +# # @param ppa_options # Supplies options to be passed to the `add-apt-repository` command. # @@ -122,6 +125,7 @@ Hash $include_defaults = $apt::params::include_defaults, String $provider = $apt::params::provider, String $keyserver = $apt::params::keyserver, + Optional[String] $key_options = $apt::params::key_options, Optional[String] $ppa_options = $apt::params::ppa_options, Optional[String] $ppa_package = $apt::params::ppa_package, Optional[Hash] $backports = $apt::params::backports, diff --git a/manifests/key.pp b/manifests/key.pp index 1f9a495f54..41e78e643b 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -42,7 +42,7 @@ Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $source = undef, Pattern[/\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/] $server = $::apt::keyserver, Boolean $weak_ssl = false, - Optional[String] $options = undef, + Optional[String] $options = $::apt::key_options, ) { case $ensure { diff --git a/manifests/params.pp b/manifests/params.pp index 76f06b9ed4..4258bbde1a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -17,6 +17,7 @@ $preferences = "${root}/preferences" $preferences_d = "${root}/preferences.d" $keyserver = 'keyserver.ubuntu.com' + $key_options = undef $confs = {} $update = {} $purge = {} From da1a6d0aef5e6b22c25bc0b60a2fd6be603e677c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 14 Aug 2019 09:10:56 +0200 Subject: [PATCH 2/3] Test default keyserver for apt::key --- spec/defines/key_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 68d5fcea89..94d40cb1a0 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -379,4 +379,18 @@ def absent_apt_key(title) end end end + + describe 'defaults' do + context 'when setting keyserver on the apt class' do + let :pre_condition do + 'class { "apt": + keyserver => "keyserver.example.com", + }' + end + + it 'uses default keyserver' do + is_expected.to contain_apt_key(title).with_server('keyserver.example.com') + end + end + end end From 0de37ff9c2830c7399bc52b4faf0ebe9230c395e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 14 Aug 2019 09:13:51 +0200 Subject: [PATCH 3/3] Test default key_options for apt::key --- spec/defines/key_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 94d40cb1a0..ad715d6e59 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -392,5 +392,17 @@ def absent_apt_key(title) is_expected.to contain_apt_key(title).with_server('keyserver.example.com') end end + + context 'when setting key_options on the apt class' do + let :pre_condition do + 'class { "apt": + key_options => "http-proxy=http://proxy.example.com:8080", + }' + end + + it 'uses default keyserver' do + is_expected.to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080') + end + end end end