Skip to content

Commit

Permalink
Rework apt to use packagecloud repos as well (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
William Yardley committed Sep 26, 2017
1 parent 58d53c3 commit ea5c9da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
15 changes: 10 additions & 5 deletions manifests/repo/apt.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# puppetlabs-apt
# puppetlabs-stdlib
class rabbitmq::repo::apt(
$location = 'http://www.rabbitmq.com/debian/',
$release = 'testing',
$location = 'https://packagecloud.io/rabbitmq/rabbitmq-server',
$repos = 'main',
$include_src = false,
$key = '0A9AF2115F4687BD29803A206B73A36E6026DFCA',
Expand All @@ -19,10 +18,10 @@
-> Class['apt::update']
-> Package<| title == 'rabbitmq-server' |>

$osname = downcase($facts['os']['name'])
apt::source { 'rabbitmq':
ensure => present,
location => $location,
release => $release,
location => "${location}/${osname}",
repos => $repos,
include => { 'src' => $include_src },
key => {
Expand All @@ -33,12 +32,18 @@
architecture => $architecture,
}

# We also need to ensure the packagecloud GPG key - the package itself is
# signed with the RMQ signing key, but we need the repo's key as well.
apt::key { 'packagecloud':
id => '418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB',
}

if $pin != '' {
validate_re($pin, '\d{1,4}')
apt::pin { 'rabbitmq':
packages => '*',
priority => $pin,
origin => 'www.rabbitmq.com',
origin => 'packagecloud.io',
}
}
}
16 changes: 9 additions & 7 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@
it 'adds a repo with default values' do
is_expected.to contain_apt__source('rabbitmq').
with_ensure('present').
with_location('http://www.rabbitmq.com/debian/').
with_release('testing').
with_location("https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}").
with_release(nil).
with_repos('main')
end
it do
is_expected.to contain_apt__key('packagecloud').
with_id('418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB')
end
else
it { is_expected.not_to contain_class('rabbitmq::repo::apt') }
it { is_expected.not_to contain_apt__souce('rabbitmq') }
Expand All @@ -82,8 +86,7 @@
describe 'it sets up an apt::source' do
it {
is_expected.to contain_apt__source('rabbitmq').with(
'location' => 'http://www.rabbitmq.com/debian/',
'release' => 'testing',
'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}",
'repos' => 'main',
'key' => '{"id"=>"0A9AF2115F4687BD29803A206B73A36E6026DFCA", "source"=>"https://www.rabbitmq.com/rabbitmq-release-signing-key.asc", "content"=>:undef}'
)
Expand All @@ -97,8 +100,7 @@
describe 'it sets up an apt::source and pin' do
it {
is_expected.to contain_apt__source('rabbitmq').with(
'location' => 'http://www.rabbitmq.com/debian/',
'release' => 'testing',
'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}",
'repos' => 'main',
'key' => '{"id"=>"0A9AF2115F4687BD29803A206B73A36E6026DFCA", "source"=>"https://www.rabbitmq.com/rabbitmq-release-signing-key.asc", "content"=>:undef}'
)
Expand All @@ -108,7 +110,7 @@
is_expected.to contain_apt__pin('rabbitmq').with(
'packages' => '*',
'priority' => '700',
'origin' => 'www.rabbitmq.com'
'origin' => 'packagecloud.io'
)
}
end
Expand Down

0 comments on commit ea5c9da

Please sign in to comment.