Skip to content

Commit

Permalink
Merge pull request #14 from ericwilliamson/task/master/PE-16566-downl…
Browse files Browse the repository at this point in the history
…oad-gpg-key

(PE-16566) Add method to download life support gpg key
  • Loading branch information
tvpartytonight authored Jul 12, 2016
2 parents 8f2874f + df1f14b commit 99c5008
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/beaker-pe/install/pe_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ def do_install hosts, opts = {}
hosts_agent_only, hosts_not_agent_only = [], hosts.dup
end

# On July 8th, 2016, the GPG key used to sign repos inside PE tarballs
# expired. Add a temporary, extended key to the host first so that it
# can still install those old PE tarballs.
add_extended_gpg_key_to_hosts(hosts, opts)

# Set PE distribution for all the hosts, create working dir
use_all_tar = ENV['PE_USE_ALL_TAR'] == 'true'
hosts.each do |host|
Expand Down Expand Up @@ -516,6 +521,26 @@ def use_meep?(version)
!version_is_less(version, MEEP_CUTOVER_VERSION)
end

# On July 8th, 2016, the gpg key that was shipped and used to sign repos in
# PE tarballs expired. This affects all PE version earlier then 3.8.5, and
# versions between 2015.2 to 2016.1.2.
#
# PE 3.8.5 and 2016.1.2 shipped with a version of the key that had it's
# expiration date extended by 6 months (to Janurary 2017).
def add_extended_gpg_key_to_hosts(hosts, opts)
hosts.each do |host|
# RPM based platforms do not seem to be effected by an expired GPG key,
# while deb based platforms are failing.
if host['platform'] =~ /debian|ubuntu/
host_ver = host['pe_ver'] || opts['pe_ver']

if version_is_less(host_ver, '3.8.5') || (!version_is_less(host_ver, '2015.2.0') && version_is_less(host_ver, '2016.1.2'))
on(host, 'curl http://apt.puppetlabs.com/pubkey.gpg | apt-key add -')
end
end
end
end

# Set installer options on the passed *host* according to current
# version.
#
Expand Down
73 changes: 73 additions & 0 deletions spec/beaker-pe/install/pe_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,79 @@ def slice_installer_options(host)
end
end

describe 'add_extended_gpg_key_to_hosts' do
let(:on_cmd) { 'curl http://apt.puppetlabs.com/pubkey.gpg | apt-key add -' }
let(:deb_host) do
host = hosts.first
host['platform'] = 'debian'
host
end

context 'mixed platforms' do
before(:each) do
hosts[0]['platform'] = 'centos'
hosts[1]['platform'] = 'debian'
hosts[2]['platform'] = 'ubuntu'
end

it 'does nothing on el platforms' do
expect(subject).not_to receive(:on).with(hosts[0], on_cmd)
subject.add_extended_gpg_key_to_hosts(hosts, opts)
end

it 'installs key on debian based platforms' do
expect(subject).to receive(:on).with(hosts[1], on_cmd)
expect(subject).to receive(:on).with(hosts[2], on_cmd)
subject.add_extended_gpg_key_to_hosts(hosts, opts)
end
end

context 'mixed pe_versions' do
before(:each) do
hosts[0]['platform'] = 'debian'
hosts[0]['pe_ver'] = '2016.2.0'
hosts[1]['platform'] = 'debian'
hosts[1]['pe_ver'] = '3.8.4'
end

it 'adds key to required hosts' do
expect(subject).not_to receive(:on).with(hosts[0], on_cmd)
expect(subject).to receive(:on).with(hosts[1], on_cmd)
subject.add_extended_gpg_key_to_hosts(hosts, opts)
end
end

context 'PE versions earlier than 3.8.5' do
['3.3.2', '3.7.3', '3.8.2'].each do |pe_ver|
it "Adds key on PE #{pe_ver}" do
deb_host['pe_ver'] = pe_ver
expect(subject).to receive(:on).with(deb_host, on_cmd)
subject.add_extended_gpg_key_to_hosts(hosts, opts)
end
end
end

context 'PE versions between 2015.2.0 and 2016.1.1' do
['2015.2.0', '2015.3.1', '2016.1.1'].each do |pe_ver|
it "Adds key on PE #{pe_ver}" do
deb_host['pe_ver'] = pe_ver
expect(subject).to receive(:on).with(deb_host, on_cmd)
subject.add_extended_gpg_key_to_hosts(hosts, opts)
end
end
end

['3.8.5', '3.8.6', '2016.1.2', '2016.2.0'].each do |pe_ver|
context "PE #{pe_ver}" do
it 'does nothing' do
deb_host['pe_ver'] = pe_ver
expect(subject).not_to receive(:on).with(deb_host, on_cmd)
subject.add_extended_gpg_key_to_hosts(hosts, opts)
end
end
end
end

describe 'fetch_pe' do

it 'can push a local PE .tar.gz to a host and unpack it' do
Expand Down

0 comments on commit 99c5008

Please sign in to comment.