Skip to content

Commit 6714140

Browse files
committed
(maint) Add ability to switch between puppet4 and puppet5 repos
1 parent d5bcfdc commit 6714140

1 file changed

Lines changed: 38 additions & 5 deletions

File tree

spec/spec_helper_acceptance.rb

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,67 @@
22
require 'beaker/puppet_install_helper'
33
require 'beaker/module_install_helper'
44

5+
def use_puppet5
6+
env_var = 'PUPPET_INSTALL_VERSION'
7+
((ENV[env_var] =~ %r{2018}) || !ENV.include?(env_var)) ? true : false
8+
end
9+
10+
def build_url(platform)
11+
use_pup5 = use_puppet5
12+
if use_pup5
13+
url5 = 'http://%{mngr}.puppetlabs.com/%{dir}puppet5-release%{plat}'
14+
case platform
15+
when 'el' then url5 % { mngr: 'yum', dir: 'puppet5/', plat: '-el-' }
16+
when 'fedora' then url5 % { mngr: 'yum', dir: 'puppet5/', plat: '-fedora-' }
17+
when 'debian', 'ubuntu' then url5 % { mngr: 'apt', dir: '', plat: '-' }
18+
else
19+
raise "build_url() called with unsupported platform '#{platform}'"
20+
end
21+
else
22+
url4 = 'http://%{mngr}.puppetlabs.com/puppetlabs-release-pc1%{plat}'
23+
case platform
24+
when 'el' then url4 % { mngr: 'yum', plat: '-el-' }
25+
when 'fedora' then url4 % { mngr: 'yum', plat: '-fedora-' }
26+
when 'debian', 'ubuntu' then url4 % { mngr: 'apt', plat: '-' }
27+
else
28+
raise "build_url() called with unsupported platform '#{platform}'"
29+
end
30+
end
31+
end
32+
533
hosts.each do |host|
634
if host['platform'] =~ %r{debian}
735
on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc'
836
end
937
# install_puppet
1038
if host['platform'] =~ %r{el-(5|6|7)}
1139
relver = Regexp.last_match(1)
12-
on host, "rpm -ivh http://yum.puppetlabs.com/puppet5/puppet5-release-el-#{relver}.noarch.rpm"
40+
on host, "rpm -ivh #{build_url('el')}#{relver}.noarch.rpm"
1341
on host, 'yum install -y puppetserver'
1442
elsif host['platform'] =~ %r{fedora-(\d+)}
1543
relver = Regexp.last_match(1)
16-
on host, "rpm -ivh http://yum.puppetlabs.com/puppet5/puppet5-release-fedora-#{relver}.noarch.rpm"
44+
on host, "rpm -ivh #{build_url('fedora')}#{relver}.noarch.rpm"
1745
on host, 'yum install -y puppetserver'
1846
elsif host['platform'] =~ %r{(ubuntu|debian)}
1947
unless host.check_for_package 'curl'
2048
on host, 'apt-get install -y curl'
2149
end
2250
# For openjdk8
23-
if host['platform'].version == '8'
51+
use_pup5 = use_puppet5
52+
if host['platform'].version == '8' && use_pup5
2453
create_remote_file(host,
2554
'/etc/apt/sources.list.d/jessie-backports.list',
2655
'deb http://httpredir.debian.org/debian jessie-backports main')
2756
on host, 'apt-get -y -m update'
2857
on host, 'apt-get install -y -t jessie-backports openjdk-8-jre-headless'
2958
end
3059
on host, 'apt-get install apt-transport-https --assume-yes'
31-
on host, 'curl -O http://apt.puppetlabs.com/puppet5-release-$(lsb_release -c -s).deb'
32-
on host, 'dpkg -i puppet5-release-$(lsb_release -c -s).deb'
60+
on host, "curl -O #{build_url('debian')}$(lsb_release -c -s).deb"
61+
if use_pup5
62+
on host, 'dpkg -i puppet5-release-$(lsb_release -c -s).deb'
63+
else
64+
on host, 'dpkg -i puppetlabs-release-pc1-$(lsb_release -c -s).deb'
65+
end
3366
on host, 'apt-get -y -m update'
3467
on host, 'apt-get install -y puppetserver'
3568
else

0 commit comments

Comments
 (0)