Skip to content

Commit b9212ab

Browse files
committed
(maint) Add ability to switch between puppet4 and puppet5 repos
1 parent 37e4335 commit b9212ab

1 file changed

Lines changed: 42 additions & 4 deletions

File tree

spec/spec_helper_acceptance.rb

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,64 @@
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+
if use_puppet4?
11+
url4 = 'http://%{mngr}.puppetlabs.com/puppetlabs-release-pc1%{plat}'
12+
case platform
13+
when 'el' then url4 % { mngr: 'yum', plat: '-el-' }
14+
when 'fedora' then url4 % { mngr: 'yum', plat: '-fedora-' }
15+
when 'debian', 'ubuntu' then url4 % { mngr: 'apt', plat: '-' }
16+
else
17+
raise "build_url() called with unsupported platform '#{platform}'"
18+
end
19+
else
20+
url5 = 'http://%{mngr}.puppetlabs.com/%{dir}puppet5-release%{plat}'
21+
case platform
22+
when 'el' then url5 % { mngr: 'yum', dir: 'puppet5/', plat: '-el-' }
23+
when 'fedora' then url5 % { mngr: 'yum', dir: 'puppet5/', plat: '-fedora-' }
24+
when 'debian', 'ubuntu' then url5 % { mngr: 'apt', dir: '', plat: '-' }
25+
else
26+
raise "build_url() called with unsupported platform '#{platform}'"
27+
end
28+
end
29+
end
30+
531
hosts.each do |host|
632
if host['platform'] =~ %r{debian}
733
on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc'
834
end
935
# install_puppet
1036
if host['platform'] =~ %r{el-(5|6|7)}
1137
relver = Regexp.last_match(1)
12-
on host, "rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-pc1-el-#{relver}.noarch.rpm"
38+
on host, "rpm -ivh #{build_url('el')}#{relver}.noarch.rpm"
1339
on host, 'yum install -y puppetserver'
1440
elsif host['platform'] =~ %r{fedora-(\d+)}
1541
relver = Regexp.last_match(1)
16-
on host, "rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-pc1-fedora-#{relver}.noarch.rpm"
42+
on host, "rpm -ivh #{build_url('fedora')}#{relver}.noarch.rpm"
1743
on host, 'yum install -y puppetserver'
1844
elsif host['platform'] =~ %r{(ubuntu|debian)}
1945
unless host.check_for_package 'curl'
2046
on host, 'apt-get install -y curl'
2147
end
48+
# For openjdk8
49+
if host['platform'].version == '8' && !use_puppet4?
50+
create_remote_file(host,
51+
'/etc/apt/sources.list.d/jessie-backports.list',
52+
'deb http://httpredir.debian.org/debian jessie-backports main')
53+
on host, 'apt-get -y -m update'
54+
on host, 'apt-get install -y -t jessie-backports openjdk-8-jre-headless'
55+
end
2256
on host, 'apt-get install apt-transport-https --assume-yes'
23-
on host, 'curl -O http://apt.puppetlabs.com/puppetlabs-release-pc1-$(lsb_release -c -s).deb'
24-
on host, 'dpkg -i puppetlabs-release-pc1-$(lsb_release -c -s).deb'
57+
on host, "curl -O #{build_url('debian')}$(lsb_release -c -s).deb"
58+
if use_puppet4?
59+
on host, 'dpkg -i puppetlabs-release-pc1-$(lsb_release -c -s).deb'
60+
else
61+
on host, 'dpkg -i puppet5-release-$(lsb_release -c -s).deb'
62+
end
2563
on host, 'apt-get -y -m update'
2664
on host, 'apt-get install -y puppetserver'
2765
else

0 commit comments

Comments
 (0)