From bbec706b5da9d9e2ea0bedbc73be8d38f31d4cd8 Mon Sep 17 00:00:00 2001 From: tphoney Date: Fri, 27 Jul 2018 11:04:44 +0100 Subject: [PATCH] (MODULES-7540) add apt-transport-https with https --- manifests/source.pp | 5 +++++ spec/defines/source_spec.rb | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/manifests/source.pp b/manifests/source.pp index afbb27a..724f5f3 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -32,6 +32,11 @@ define apt::source( if ! $location { fail('cannot create a source entry without specifying a location') } + # Newer oses, do not need the package for HTTPS transport. + $_transport_https_releases = [ 'wheezy', 'jessie', 'stretch', 'trusty', 'xenial' ] + if $_release in $_transport_https_releases and $location =~ /(?i:^https:\/\/)/ { + ensure_packages('apt-transport-https') + } } $includes = merge($::apt::include_defaults, $include) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index ee88132..38f5b9d 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -40,6 +40,7 @@ describe 'apt::source' do it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n}) + is_expected.not_to contain_package('apt-transport-https') } end end @@ -202,6 +203,50 @@ describe 'apt::source' do } end + context 'with a https location, install apt-transport-https' do + let :facts do + { + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, + lsbdistid: 'Debian', + lsbdistcodename: 'jessie', + osfamily: 'Debian', + puppetversion: Puppet.version, + } + end + let :params do + { + location: 'HTTPS://foo.bar', + allow_unsigned: false, + } + end + + it { + is_expected.to contain_package('apt-transport-https') + } + end + + context 'with a https location, do not install apt-transport-https on oses not in list eg buster' do + let :facts do + { + os: { family: 'Debian', name: 'Debian', release: { major: '10', full: '10.0' } }, + lsbdistid: 'Debian', + lsbdistcodename: 'buster', + osfamily: 'Debian', + puppetversion: Puppet.version, + } + end + let :params do + { + location: 'https://foo.bar', + allow_unsigned: false, + } + end + + it { + is_expected.not_to contain_package('apt-transport-https') + } + end + context 'with architecture equals x86_64' do let :facts do { -- 2.32.3