|
2 | 2 | require 'beaker/puppet_install_helper' |
3 | 3 | require 'beaker/module_install_helper' |
4 | 4 |
|
| 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 | + |
5 | 31 | hosts.each do |host| |
6 | 32 | if host['platform'] =~ %r{debian} |
7 | 33 | on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' |
8 | 34 | end |
9 | 35 | # install_puppet |
10 | 36 | if host['platform'] =~ %r{el-(5|6|7)} |
11 | 37 | 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" |
13 | 39 | on host, 'yum install -y puppetserver' |
14 | 40 | elsif host['platform'] =~ %r{fedora-(\d+)} |
15 | 41 | 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" |
17 | 43 | on host, 'yum install -y puppetserver' |
18 | 44 | elsif host['platform'] =~ %r{(ubuntu|debian)} |
19 | 45 | unless host.check_for_package 'curl' |
20 | 46 | on host, 'apt-get install -y curl' |
21 | 47 | 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 |
22 | 56 | 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 |
25 | 63 | on host, 'apt-get -y -m update' |
26 | 64 | on host, 'apt-get install -y puppetserver' |
27 | 65 | else |
|
0 commit comments