Skip to content

Commit 9fedb0d

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

1 file changed

Lines changed: 44 additions & 4 deletions

File tree

spec/spec_helper_acceptance.rb

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +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/puppetlabs-release-pc1-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/puppetlabs-release-pc1-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
49+
# For openjdk8
50+
use_pup4 = use_puppet4
51+
if host['platform'].version == '8' && !use_pup4
52+
create_remote_file(host,
53+
'/etc/apt/sources.list.d/jessie-backports.list',
54+
'deb http://httpredir.debian.org/debian jessie-backports main')
55+
on host, 'apt-get -y -m update'
56+
on host, 'apt-get install -y -t jessie-backports openjdk-8-jre-headless'
57+
end
2258
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'
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
2565
on host, 'apt-get -y -m update'
2666
on host, 'apt-get install -y puppetserver'
2767
else

0 commit comments

Comments
 (0)