Skip to content

Commit 6e91059

Browse files
committed
(maint) Add ability to switch between puppet4 and puppet5 repos
1 parent 7d297df commit 6e91059

1 file changed

Lines changed: 37 additions & 5 deletions

File tree

spec/spec_helper_acceptance.rb

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

5+
def use_puppet4
6+
(ENV['PUPPET_INSTALL_VERSION'] =~ %r{2016}) ? true : false
7+
end
8+
9+
def build_url(platform)
10+
use_pup4 = use_puppet4
11+
if use_pup4
12+
url4 = 'http://%{mngr}.puppetlabs.com/puppetlabs-release-pc1%{plat}'
13+
case platform
14+
when 'el' then url4 % { mngr: 'yum', plat: '-el-' }
15+
when 'fedora' then url4 % { mngr: 'yum', plat: '-fedora-' }
16+
when 'debian', 'ubuntu' then url4 % { mngr: 'apt', plat: '-' }
17+
else
18+
raise "build_url() called with unsupported platform '#{platform}'"
19+
end
20+
else
21+
url5 = 'http://%{mngr}.puppetlabs.com/%{dir}puppet5-release%{plat}'
22+
case platform
23+
when 'el' then url5 % { mngr: 'yum', dir: 'puppet5/', plat: '-el-' }
24+
when 'fedora' then url5 % { mngr: 'yum', dir: 'puppet5/', plat: '-fedora-' }
25+
when 'debian', 'ubuntu' then url5 % { mngr: 'apt', dir: '', plat: '-' }
26+
else
27+
raise "build_url() called with unsupported platform '#{platform}'"
28+
end
29+
end
30+
end
31+
532
hosts.each do |host|
633
if host['platform'] =~ %r{debian}
734
on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc'
835
end
936
# install_puppet
1037
if host['platform'] =~ %r{el-(5|6|7)}
1138
relver = Regexp.last_match(1)
12-
on host, "rpm -ivh http://yum.puppetlabs.com/puppet5/puppet5-release-el-#{relver}.noarch.rpm"
39+
on host, "rpm -ivh #{build_url('el')}#{relver}.noarch.rpm"
1340
on host, 'yum install -y puppetserver'
1441
elsif host['platform'] =~ %r{fedora-(\d+)}
1542
relver = Regexp.last_match(1)
16-
on host, "rpm -ivh http://yum.puppetlabs.com/puppet5/puppet5-release-fedora-#{relver}.noarch.rpm"
43+
on host, "rpm -ivh #{build_url('fedora')}#{relver}.noarch.rpm"
1744
on host, 'yum install -y puppetserver'
1845
elsif host['platform'] =~ %r{(ubuntu|debian)}
1946
unless host.check_for_package 'curl'
2047
on host, 'apt-get install -y curl'
2148
end
2249
# For openjdk8
23-
if host['platform'].version == '8'
50+
use_pup4 = use_puppet4
51+
if host['platform'].version == '8' && !use_pup4
2452
create_remote_file(host,
2553
'/etc/apt/sources.list.d/jessie-backports.list',
2654
'deb http://httpredir.debian.org/debian jessie-backports main')
2755
on host, 'apt-get -y -m update'
2856
on host, 'apt-get install -y -t jessie-backports openjdk-8-jre-headless'
2957
end
3058
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'
59+
on host, "curl -O #{build_url('debian')}$(lsb_release -c -s).deb"
60+
if use_pup4
61+
on host, 'dpkg -i puppetlabs-release-pc1-$(lsb_release -c -s).deb'
62+
else
63+
on host, 'dpkg -i puppet5-release-$(lsb_release -c -s).deb'
64+
end
3365
on host, 'apt-get -y -m update'
3466
on host, 'apt-get install -y puppetserver'
3567
else

0 commit comments

Comments
 (0)