beaker-puppet 1.14.0 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/beaker-puppet/install_utils/foss_utils.rb +111 -4
- data/lib/beaker-puppet/install_utils/puppet5.rb +17 -3
- data/lib/beaker-puppet/install_utils/puppet_utils.rb +89 -2
- data/lib/beaker-puppet/version.rb +1 -1
- data/setup/common/025_StopFirewall.rb +1 -19
- data/spec/beaker-puppet/install_utils/foss_utils_spec.rb +87 -0
- data/spec/beaker-puppet/install_utils/puppet5_spec.rb +20 -4
- data/spec/beaker-puppet/install_utils/puppet_utils_spec.rb +63 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d2efb4c745da178b7a32980b2057ceb9a80049a
|
4
|
+
data.tar.gz: 100e06d7c5847f1897e7b99723ff2a7d073c4125
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3461becc565e5ca0f2144cffe9d4aca0c0d88dba63c3bb6bb434911a13b061d73b804247d50b66ee03ad259187060b242d2af3c4747e5dc71b96e5cd9efde728
|
7
|
+
data.tar.gz: 4450d6299416020c5f4635a712e48502da7569f53d92cb305f83f82bc721ac959668b2f8789c2949652a58312a30c4a0941032f9264acef1d07e3cd84b625b71
|
@@ -31,6 +31,9 @@ module Beaker
|
|
31
31
|
# Github's ssh signature for cloning via ssh
|
32
32
|
GitHubSig = 'github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
|
33
33
|
|
34
|
+
# URL for public nightly builds
|
35
|
+
DEFAULT_NIGHTLY_BUILDS_URL = 'http://nightlies.puppet.com'
|
36
|
+
|
34
37
|
# lookup project-specific git environment variables
|
35
38
|
# PROJECT_VAR or VAR otherwise return the default
|
36
39
|
#
|
@@ -41,6 +44,21 @@ module Beaker
|
|
41
44
|
project_name && ENV[project_specific_name] || ENV[env_variable_name] || default
|
42
45
|
end
|
43
46
|
|
47
|
+
# @return [Boolean] Whether Puppet's internal builds are accessible from all the SUTs
|
48
|
+
def dev_builds_accessible?
|
49
|
+
block_on hosts do |host|
|
50
|
+
return false unless dev_builds_accessible_on?(host)
|
51
|
+
end
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
# @param [Host] A beaker host
|
56
|
+
# @return [Boolean] Whether Puppet's internal builds are accessible from the host
|
57
|
+
def dev_builds_accessible_on?(host)
|
58
|
+
result = on(host, %(curl -fI "#{Puppet5::DEFAULT_DEV_BUILDS_URL}"), accept_all_exit_codes: true)
|
59
|
+
return result.exit_code.zero?
|
60
|
+
end
|
61
|
+
|
44
62
|
# @param [String] project_name
|
45
63
|
# @param [String] git_fork When not provided will use PROJECT_FORK environment variable
|
46
64
|
# @param [String] git_server When not provided will use PROJECT_SERVER environment variable
|
@@ -309,7 +327,7 @@ module Beaker
|
|
309
327
|
nil
|
310
328
|
end
|
311
329
|
|
312
|
-
#Install Puppet Agent based on specified hosts using provided options
|
330
|
+
# Install Puppet Agent or Puppet as a gem based on specified hosts using provided options
|
313
331
|
# @example will install puppet-agent 1.1.0 from native puppetlabs provided packages wherever possible and will fail over to gem installing latest puppet
|
314
332
|
# install_puppet_agent_on(hosts, {
|
315
333
|
# :puppet_agent_version => '1.1.0',
|
@@ -331,7 +349,9 @@ module Beaker
|
|
331
349
|
# @option opts [String] :puppet_gem_version Version of puppet to install via gem if no puppet-agent package is available
|
332
350
|
# @option opts [String] :mac_download_url Url to download msi pattern of %url%/puppet-agent-%version%.msi
|
333
351
|
# @option opts [String] :win_download_url Url to download dmg pattern of %url%/puppet-agent-%version%.msi
|
334
|
-
# @option opts [String] :puppet_collection Defaults to 'pc1'
|
352
|
+
# @option opts [String] :puppet_collection Collection to install from. Defaults to 'pc1' (contains the latest
|
353
|
+
# puppet 4). Other valid options are 'puppet' (for the latest release), 'puppet5' (for the latest puppet 5),
|
354
|
+
# or 'puppet6' (for the latest puppet 6). Only works for platforms that rely on repos.
|
335
355
|
# @option opts [Boolean] :run_in_parallel Whether to run on each host in parallel.
|
336
356
|
#
|
337
357
|
# @return nil
|
@@ -339,13 +359,24 @@ module Beaker
|
|
339
359
|
# @raise [FailTest] When error occurs during the actual installation process
|
340
360
|
def install_puppet_agent_on(hosts, opts = {})
|
341
361
|
opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts)
|
342
|
-
opts[:puppet_collection] ||= 'pc1' #hi! i'm case sensitive! be careful!
|
343
362
|
opts[:puppet_agent_version] ||= opts[:version] #backwards compatability with old parameter name
|
363
|
+
opts[:puppet_collection] ||= puppet_collection_for(:puppet_agent, opts[:puppet_agent_version]) || 'pc1'
|
364
|
+
|
365
|
+
opts[:puppet_collection].downcase! # the collection names are case sensitive
|
344
366
|
|
345
367
|
run_in_parallel = run_in_parallel? opts, @options, 'install'
|
346
368
|
block_on hosts, { :run_in_parallel => run_in_parallel } do |host|
|
347
|
-
|
369
|
+
# AIO refers to FOSS agents that contain puppet 4+, that is, puppet-agent packages
|
370
|
+
# in the 1.x series, or the 5.x series, or later. Previous versions are not supported,
|
371
|
+
# so 'aio' is the only role that makes sense here.
|
372
|
+
add_role(host, 'aio')
|
348
373
|
package_name = nil
|
374
|
+
|
375
|
+
# If inside the Puppet VPN, install from development builds.
|
376
|
+
if opts[:puppet_agent_version] && dev_builds_accessible_on?(host)
|
377
|
+
return install_puppet_agent_from_dev_builds_on(host, opts[:puppet_agent_version])
|
378
|
+
end
|
379
|
+
|
349
380
|
case host['platform']
|
350
381
|
when /el-|redhat|fedora|sles|centos|cisco_/
|
351
382
|
package_name = 'puppet-agent'
|
@@ -1341,6 +1372,82 @@ module Beaker
|
|
1341
1372
|
on host, "certutil -v -addstore Root C:\\Windows\\Temp\\#{cert_name}.pem"
|
1342
1373
|
end
|
1343
1374
|
|
1375
|
+
# Install puppetserver on the target host from released repos,
|
1376
|
+
# nightlies, or Puppet's internal build servers.
|
1377
|
+
#
|
1378
|
+
# The default behavior is to install the latest release of puppetserver
|
1379
|
+
# from the 'puppet' official repo.
|
1380
|
+
#
|
1381
|
+
# @param [Host] host A beaker host
|
1382
|
+
# @option opts [String] :version Specific puppetserver version.
|
1383
|
+
# If set, this overrides all other options and installs the specific
|
1384
|
+
# version from Puppet's internal build servers.
|
1385
|
+
# @option opts [Boolean] :nightlies Whether to install from nightlies.
|
1386
|
+
# Defaults to false.
|
1387
|
+
# @option opts [String] :release_stream Which release stream to install
|
1388
|
+
# repos from. Defaults to 'puppet', which installs the latest released
|
1389
|
+
# version. Other valid values are puppet5, puppet6.
|
1390
|
+
# @option opts [String] :nightly_builds_url Custom nightly builds URL.
|
1391
|
+
# Defaults to {DEFAULT_NIGHTLY_BUILDS_URL}.
|
1392
|
+
# @option opts [String] :yum_nightly_builds_url Custom nightly builds
|
1393
|
+
# URL for yum. Defaults to {DEFAULT_NIGHTLY_BUILDS_URL}/yum when using
|
1394
|
+
# the default :nightly_builds_url value. Otherwise, defaults to
|
1395
|
+
# {DEFAULT_NIGHTLY_BUILDS_URL}.
|
1396
|
+
# @option opts [String] :apt_nightly_builds_url Custom nightly builds
|
1397
|
+
# URL for apt. Defaults to {DEFAULT_NIGHTLY_BUILDS_URL}/apt when using
|
1398
|
+
# the default :nightly_builds_url value. Otherwise, defaults to
|
1399
|
+
# {DEFAULT_NIGHTLY_BUILDS_URL}.
|
1400
|
+
# @option opts [String] :dev_builds_url Custom internal builds URL.
|
1401
|
+
# Defaults to {DEFAULT_DEV_BUILDS_URL}.
|
1402
|
+
def install_puppetserver_on(host, opts = {})
|
1403
|
+
# If the version is anything other than 'latest', install that specific version from internal dev builds
|
1404
|
+
if opts[:version] && opts[:version].strip != 'latest'
|
1405
|
+
dev_builds_url = opts[:dev_builds_url] || Puppet5::DEFAULT_DEV_BUILDS_URL
|
1406
|
+
build_yaml_uri = %(#{dev_builds_url}/puppetserver/#{opts[:version]}/artifacts/#{opts[:version]}.yaml)
|
1407
|
+
unless link_exists?(build_yaml_uri)
|
1408
|
+
raise "Can't find a downloadable puppetserver package; metadata at #{build_yaml_uri} is missing or inaccessible."
|
1409
|
+
end
|
1410
|
+
return install_from_build_data_url('puppetserver', build_yaml_uri, host)
|
1411
|
+
end
|
1412
|
+
|
1413
|
+
# Determine the release stream's name, for repo selection. The default
|
1414
|
+
# is 'puppet', which installs the latest release. Other valid values
|
1415
|
+
# are 'puppet5' or 'puppet6'.
|
1416
|
+
release_stream = opts[:release_stream] || 'puppet'
|
1417
|
+
|
1418
|
+
# Installing a release repo will call configure_type_defaults_on,
|
1419
|
+
# which will try and fail to add PE defaults by default. This is a
|
1420
|
+
# FOSS install method, so we don't want that. Set the type to AIO,
|
1421
|
+
# which refers to FOSS with puppet 4+ (note that a value of `:foss`
|
1422
|
+
# here would be incorrect - that refers to FOSS puppet 3 only).
|
1423
|
+
host[:type] = :aio
|
1424
|
+
|
1425
|
+
if opts[:nightlies]
|
1426
|
+
release_stream += '-nightly'
|
1427
|
+
# Determine the repo URLs; Use Puppet's nightly builds by default.
|
1428
|
+
nightly_builds_url = opts[:nightly_builds_url] || DEFAULT_NIGHTLY_BUILDS_URL
|
1429
|
+
if nightly_builds_url == DEFAULT_NIGHTLY_BUILDS_URL
|
1430
|
+
# Puppet's nightlies need particular paths for these:
|
1431
|
+
yum_nightly_builds_url = opts[:yum_nightly_builds_url] || nightly_builds_url + '/yum'
|
1432
|
+
apt_nightly_builds_url = opts[:apt_nightly_builds_url] || nightly_builds_url + '/apt'
|
1433
|
+
else
|
1434
|
+
# If custom yum and apt urls are supplied, use them, otherwise
|
1435
|
+
# just assume the nightly_builds_url is fine.
|
1436
|
+
yum_nightly_builds_url = opts[:yum_nightly_builds_url] || nightly_builds_url
|
1437
|
+
apt_nightly_builds_url = opts[:apt_nightly_builds_url] || nightly_builds_url
|
1438
|
+
end
|
1439
|
+
install_puppetlabs_release_repo_on(host, release_stream,
|
1440
|
+
release_yum_repo_url: yum_nightly_builds_url,
|
1441
|
+
release_apt_repo_url: apt_nightly_builds_url)
|
1442
|
+
else
|
1443
|
+
install_puppetlabs_release_repo_on(host, release_stream)
|
1444
|
+
end
|
1445
|
+
|
1446
|
+
install_package(host, 'puppetserver')
|
1447
|
+
|
1448
|
+
logger.notify("Installed puppetserver version #{puppetserver_version_on(host)} on #{host}")
|
1449
|
+
end
|
1450
|
+
|
1344
1451
|
# Ensures Puppet and dependencies are no longer installed on host(s).
|
1345
1452
|
#
|
1346
1453
|
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
@@ -4,9 +4,11 @@ module Beaker
|
|
4
4
|
module DSL
|
5
5
|
module InstallUtils
|
6
6
|
module Puppet5
|
7
|
-
|
8
7
|
include Beaker::DSL::InstallUtils::FOSSDefaults
|
9
8
|
|
9
|
+
# Base URL for internal Puppet Inc. builds
|
10
|
+
DEFAULT_DEV_BUILDS_URL = 'http://builds.delivery.puppetlabs.net'
|
11
|
+
|
10
12
|
# grab build json from the builds server
|
11
13
|
#
|
12
14
|
# @param [String] sha_yaml_url URL to the <SHA>.yaml file containing the
|
@@ -183,8 +185,7 @@ module Beaker
|
|
183
185
|
def install_from_build_data_url(project_name, sha_yaml_url, local_hosts = nil)
|
184
186
|
if !link_exists?( sha_yaml_url )
|
185
187
|
message = <<-EOF
|
186
|
-
|
187
|
-
Please update the `sha_yaml_url` parameter to the `puppet5_install` method.
|
188
|
+
Unable to locate a downloadable build of #{project_name} (tried #{sha_yaml_url})
|
188
189
|
EOF
|
189
190
|
fail_test( message )
|
190
191
|
end
|
@@ -205,6 +206,19 @@ module Beaker
|
|
205
206
|
end
|
206
207
|
end
|
207
208
|
|
209
|
+
# Install puppet-agent from an internal Puppet development build. This method only
|
210
|
+
# works inside Puppet's corporate VPN.
|
211
|
+
# @param [Host|Array<Host>] one_or_more_hosts to install the agent on
|
212
|
+
# @param [String] ref to install (this can be a tag or a long SHA)
|
213
|
+
def install_puppet_agent_from_dev_builds_on(one_or_more_hosts, ref)
|
214
|
+
block_on(one_or_more_hosts, run_in_parallel: true) do |host|
|
215
|
+
unless dev_builds_accessible_on?(host)
|
216
|
+
fail_test("Can't install puppet-agent #{ref}: unable to access Puppet's internal builds")
|
217
|
+
end
|
218
|
+
end
|
219
|
+
sha_yaml_url = File.join(DEFAULT_DEV_BUILDS_URL, 'puppet-agent', ref, 'artifacts', "#{ref}.yaml")
|
220
|
+
install_from_build_data_url('puppet-agent', sha_yaml_url, one_or_more_hosts)
|
221
|
+
end
|
208
222
|
end
|
209
223
|
end
|
210
224
|
end
|
@@ -72,8 +72,11 @@ module Beaker
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
#Given an agent_version, return the puppet collection associated with that agent version
|
76
|
-
|
75
|
+
# Given an agent_version, return the puppet collection associated with that agent version
|
76
|
+
#
|
77
|
+
# @param [String] agent_version version string or 'latest'
|
78
|
+
# @deprecated This method returns 'PC1' as the latest puppet collection;
|
79
|
+
# this is incorrect. Use {#puppet_collection_for} instead.
|
77
80
|
def get_puppet_collection(agent_version = 'latest')
|
78
81
|
collection = "PC1"
|
79
82
|
if agent_version != 'latest'
|
@@ -86,6 +89,67 @@ module Beaker
|
|
86
89
|
collection
|
87
90
|
end
|
88
91
|
|
92
|
+
# Determine the puppet collection that matches a given package version. The package
|
93
|
+
# must be one of
|
94
|
+
# * :puppet_agent (you can get this version from the `aio_agent_version_fact`)
|
95
|
+
# * :puppet
|
96
|
+
#
|
97
|
+
#
|
98
|
+
# @param package [Symbol] the package name. must be one of :puppet_agent, :puppet
|
99
|
+
# @param version [String] a version number or the string 'latest'
|
100
|
+
# @returns [String|nil] the name of the corresponding puppet collection, if any
|
101
|
+
def puppet_collection_for(package, version)
|
102
|
+
valid_packages = [
|
103
|
+
:puppet_agent,
|
104
|
+
:puppet
|
105
|
+
]
|
106
|
+
|
107
|
+
unless valid_packages.include?(package)
|
108
|
+
raise "package must be one of #{valid_packages.join(', ')}"
|
109
|
+
end
|
110
|
+
|
111
|
+
case package
|
112
|
+
when :puppet_agent, :puppet
|
113
|
+
version = version.to_s
|
114
|
+
return 'puppet' if version.strip == 'latest'
|
115
|
+
|
116
|
+
x, y, z = version.to_s.split('.').map(&:to_i)
|
117
|
+
return nil if x.nil? || y.nil? || z.nil?
|
118
|
+
|
119
|
+
pc1_x = package == :puppet ? 4 : 1
|
120
|
+
return 'pc1' if x == pc1_x
|
121
|
+
|
122
|
+
# A y version >= 99 indicates a pre-release version of the next x release
|
123
|
+
x += 1 if y >= 99
|
124
|
+
"puppet#{x}" if x > 4
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Report the version of puppet-agent installed on `host`
|
129
|
+
#
|
130
|
+
# @param [Host] host The host to act upon
|
131
|
+
# @returns [String|nil] The version of puppet-agent, or nil if puppet-agent is not installed
|
132
|
+
def puppet_agent_version_on(host)
|
133
|
+
result = on(host, facter('aio_agent_version'), accept_all_exit_codes: true)
|
134
|
+
if result.exit_code.zero?
|
135
|
+
return result.stdout.strip
|
136
|
+
end
|
137
|
+
nil
|
138
|
+
end
|
139
|
+
|
140
|
+
# Report the version of puppetserver installed on `host`
|
141
|
+
#
|
142
|
+
# @param [Host] host The host to act upon
|
143
|
+
# @returns [String|nil] The version of puppetserver, or nil if puppetserver is not installed
|
144
|
+
def puppetserver_version_on(host)
|
145
|
+
result = on(host, 'puppetserver --version', accept_all_exit_codes: true)
|
146
|
+
if result.exit_code.zero?
|
147
|
+
matched = result.stdout.strip.scan(%r{\d+\.\d+\.\d+})
|
148
|
+
return matched.last
|
149
|
+
end
|
150
|
+
nil
|
151
|
+
end
|
152
|
+
|
89
153
|
#Configure the provided hosts to be of the provided type (one of foss, aio, pe), if the host
|
90
154
|
#is already associated with a type then remove the previous settings for that type
|
91
155
|
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
@@ -165,6 +229,29 @@ module Beaker
|
|
165
229
|
end
|
166
230
|
end
|
167
231
|
|
232
|
+
# Uses puppet to stop the firewall on the given hosts. Puppet must be installed before calling this method.
|
233
|
+
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon, or a role (String or Symbol) that identifies one or more hosts.
|
234
|
+
def stop_firewall_with_puppet_on(hosts)
|
235
|
+
block_on hosts do |host|
|
236
|
+
case host['platform']
|
237
|
+
when /debian/
|
238
|
+
result = on(host, 'which iptables', accept_all_exit_codes: true)
|
239
|
+
if result.exit_code == 0
|
240
|
+
on host, 'iptables -F'
|
241
|
+
else
|
242
|
+
logger.notify("Unable to locate `iptables` on #{host['platform']}; not attempting to clear firewall")
|
243
|
+
end
|
244
|
+
when /fedora|el-7/
|
245
|
+
on host, puppet('resource', 'service', 'firewalld', 'ensure=stopped')
|
246
|
+
when /el-|centos/
|
247
|
+
on host, puppet('resource', 'service', 'iptables', 'ensure=stopped')
|
248
|
+
when /ubuntu/
|
249
|
+
on host, puppet('resource', 'service', 'ufw', 'ensure=stopped')
|
250
|
+
else
|
251
|
+
logger.notify("Not sure how to clear firewall on #{host['platform']}")
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
168
255
|
end
|
169
256
|
end
|
170
257
|
end
|
@@ -1,22 +1,4 @@
|
|
1
1
|
test_name "Stop firewall" do
|
2
2
|
skip_test 'not testing with puppetserver' unless @options['is_puppetserver']
|
3
|
-
hosts
|
4
|
-
case host['platform']
|
5
|
-
when /debian/
|
6
|
-
result = on(host, 'which iptables', accept_all_exit_codes: true)
|
7
|
-
if result.exit_code == 0
|
8
|
-
on host, 'iptables -F'
|
9
|
-
else
|
10
|
-
logger.notify("Unable to locate `iptables` on #{host['platform']}; not attempting to clear firewall")
|
11
|
-
end
|
12
|
-
when /fedora|el-7/
|
13
|
-
on host, puppet('resource', 'service', 'firewalld', 'ensure=stopped')
|
14
|
-
when /el-|centos/
|
15
|
-
on host, puppet('resource', 'service', 'iptables', 'ensure=stopped')
|
16
|
-
when /ubuntu/
|
17
|
-
on host, puppet('resource', 'service', 'ufw', 'ensure=stopped')
|
18
|
-
else
|
19
|
-
logger.notify("Not sure how to clear firewall on #{host['platform']}")
|
20
|
-
end
|
21
|
-
end
|
3
|
+
stop_firewall_with_puppet_on(hosts)
|
22
4
|
end
|
@@ -1444,6 +1444,93 @@ describe ClassMixedWithDSLInstallUtils do
|
|
1444
1444
|
end
|
1445
1445
|
end
|
1446
1446
|
|
1447
|
+
describe '#install_puppetserver_on' do
|
1448
|
+
let(:host) { make_host('master', platform: 'el-7-x86_64') }
|
1449
|
+
|
1450
|
+
context 'with default arguments' do
|
1451
|
+
it "installs the latest puppetserver from the default 'puppet' release stream" do
|
1452
|
+
expect(subject).to receive(:install_puppetlabs_release_repo_on).with(host, 'puppet')
|
1453
|
+
expect(subject).to receive(:install_package).with(host, 'puppetserver')
|
1454
|
+
subject.install_puppetserver_on(host)
|
1455
|
+
end
|
1456
|
+
end
|
1457
|
+
|
1458
|
+
context 'with a version option' do
|
1459
|
+
version = '6.6.6'
|
1460
|
+
|
1461
|
+
it 'installs puppetserver at the specific version from internal buildservers' do
|
1462
|
+
expect(subject).to receive(:install_from_build_data_url).with('puppetserver', /^#{BeakerPuppet::DEFAULT_DEV_BUILDS_URL}.*#{version}/, host)
|
1463
|
+
allow_any_instance_of(Beaker::DSL::WebHelpers).to receive(:link_exists?).and_return(true)
|
1464
|
+
subject.install_puppetserver_on(host, version: version)
|
1465
|
+
end
|
1466
|
+
|
1467
|
+
context "and a YAML metadata file isn't accessible for it" do
|
1468
|
+
it 'raises an exception' do
|
1469
|
+
allow_any_instance_of(Beaker::DSL::WebHelpers).to receive(:link_exists?).and_return(false)
|
1470
|
+
expect { subject.install_puppetserver_on(host, version: version) }.to raise_error(RuntimeError)
|
1471
|
+
end
|
1472
|
+
end
|
1473
|
+
|
1474
|
+
context 'with a custom dev builds URL' do
|
1475
|
+
dev_builds_url = 'http://builds.corp.tld'
|
1476
|
+
|
1477
|
+
it 'installs puppetserver from the custom dev builds URL' do
|
1478
|
+
expect(subject).to receive(:install_from_build_data_url).with('puppetserver', /^#{dev_builds_url}.*#{version}/, host)
|
1479
|
+
allow_any_instance_of(Beaker::DSL::WebHelpers).to receive(:link_exists?).and_return(true)
|
1480
|
+
subject.install_puppetserver_on(host, version: version, dev_builds_url: dev_builds_url)
|
1481
|
+
end
|
1482
|
+
end
|
1483
|
+
end
|
1484
|
+
|
1485
|
+
context 'with a custom release stream option' do
|
1486
|
+
it 'installs puppetserver from the custom release stream' do
|
1487
|
+
release_stream = 'puppet6'
|
1488
|
+
expect(subject).to receive(:install_puppetlabs_release_repo_on)
|
1489
|
+
.with(host, release_stream)
|
1490
|
+
expect(subject).to receive(:install_package).with(host, 'puppetserver')
|
1491
|
+
subject.install_puppetserver_on(host, release_stream: release_stream)
|
1492
|
+
end
|
1493
|
+
end
|
1494
|
+
|
1495
|
+
context 'with the nightlies option' do
|
1496
|
+
it 'installs puppetserver from the default puppet nightly repos' do
|
1497
|
+
expect(subject).to receive(:install_puppetlabs_release_repo_on)
|
1498
|
+
.with(host, 'puppet-nightly',
|
1499
|
+
release_yum_repo_url: "#{BeakerPuppet::DEFAULT_NIGHTLY_BUILDS_URL}/yum",
|
1500
|
+
release_apt_repo_url: "#{BeakerPuppet::DEFAULT_NIGHTLY_BUILDS_URL}/apt")
|
1501
|
+
subject.install_puppetserver_on(host, nightlies: true)
|
1502
|
+
end
|
1503
|
+
|
1504
|
+
context 'with custom nightlies urls' do
|
1505
|
+
custom_nightlies_url = 'http://nightlies.corp.tld'
|
1506
|
+
|
1507
|
+
it 'uses a custom general nightlies url' do
|
1508
|
+
expect(subject).to receive(:install_puppetlabs_release_repo_on)
|
1509
|
+
.with(host, 'puppet-nightly',
|
1510
|
+
release_yum_repo_url: custom_nightlies_url,
|
1511
|
+
release_apt_repo_url: custom_nightlies_url)
|
1512
|
+
subject.install_puppetserver_on(host, nightlies: true, nightly_builds_url: custom_nightlies_url)
|
1513
|
+
end
|
1514
|
+
|
1515
|
+
it 'uses a custom yum repo url' do
|
1516
|
+
expect(subject).to receive(:install_puppetlabs_release_repo_on)
|
1517
|
+
.with(host, 'puppet-nightly',
|
1518
|
+
release_yum_repo_url: custom_nightlies_url,
|
1519
|
+
release_apt_repo_url: "#{BeakerPuppet::DEFAULT_NIGHTLY_BUILDS_URL}/apt")
|
1520
|
+
subject.install_puppetserver_on(host, nightlies: true, yum_nightly_builds_url: custom_nightlies_url)
|
1521
|
+
end
|
1522
|
+
|
1523
|
+
it 'uses a custom apt repo url' do
|
1524
|
+
expect(subject).to receive(:install_puppetlabs_release_repo_on)
|
1525
|
+
.with(host, 'puppet-nightly',
|
1526
|
+
release_yum_repo_url: "#{BeakerPuppet::DEFAULT_NIGHTLY_BUILDS_URL}/yum",
|
1527
|
+
release_apt_repo_url: custom_nightlies_url)
|
1528
|
+
subject.install_puppetserver_on(host, nightlies: true, apt_nightly_builds_url: custom_nightlies_url)
|
1529
|
+
end
|
1530
|
+
end
|
1531
|
+
end
|
1532
|
+
end
|
1533
|
+
|
1447
1534
|
describe '#remove_puppet_on' do
|
1448
1535
|
supported_platforms = [ 'aix-53-power',
|
1449
1536
|
'aix-61-power',
|
@@ -368,10 +368,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
368
368
|
|
369
369
|
expect {
|
370
370
|
subject.install_from_build_data_url( 'project_name', sha_yaml_url )
|
371
|
-
}.to raise_error(
|
372
|
-
Beaker::DSL::Outcomes::FailTest,
|
373
|
-
/#{sha_yaml_url}' does not exist/
|
374
|
-
)
|
371
|
+
}.to raise_error(Beaker::DSL::Outcomes::FailTest, /project_name.*#{sha_yaml_url}/)
|
375
372
|
end
|
376
373
|
|
377
374
|
it 'runs host.install_package instead of #install_artifact_on if theres a repo_config' do
|
@@ -393,4 +390,23 @@ describe ClassMixedWithDSLInstallUtils do
|
|
393
390
|
end
|
394
391
|
end
|
395
392
|
|
393
|
+
describe '#install_puppet_agent_from_dev_builds_on' do
|
394
|
+
let(:host) { make_host('test_host', { platform: 'el-7-x86_64' }) }
|
395
|
+
let(:ref) { "sha" }
|
396
|
+
let(:sha_yaml_url) { "#{Beaker::DSL::Puppet5::DEFAULT_DEV_BUILDS_URL}/puppet-agent/#{ref}/artifacts/#{ref}.yaml" }
|
397
|
+
|
398
|
+
it 'installs puppet-agent from internal builds when they are accessible' do
|
399
|
+
expect( subject ).to receive(:block_on).with(anything, :run_in_parallel => true)
|
400
|
+
allow(subject).to receive(:dev_builds_accessible_on?).and_return(true)
|
401
|
+
allow(subject).to receive(:install_from_build_data_url).with('puppet-agent', sha_yaml_url, host)
|
402
|
+
subject.install_puppet_agent_from_dev_builds_on(host, ref)
|
403
|
+
expect(subject).to have_received(:install_from_build_data_url).with('puppet-agent', sha_yaml_url, host)
|
404
|
+
end
|
405
|
+
|
406
|
+
it 'fails the test when internal builds are inaccessible' do
|
407
|
+
expect( subject ).to receive(:block_on).with(anything, :run_in_parallel => true)
|
408
|
+
allow(subject).to receive(:dev_builds_accessible?).and_return(false)
|
409
|
+
expect { subject.install_puppet_agent_from_dev_builds_on(host, 'sha') }.to raise_error(Beaker::DSL::Outcomes::FailTest)
|
410
|
+
end
|
411
|
+
end
|
396
412
|
end
|
@@ -137,19 +137,71 @@ describe ClassMixedWithDSLInstallUtils do
|
|
137
137
|
|
138
138
|
end
|
139
139
|
|
140
|
-
describe
|
141
|
-
it
|
142
|
-
expect
|
140
|
+
describe '#puppet_collection_for' do
|
141
|
+
it 'raises an error when given an invalid package' do
|
142
|
+
expect { subject.puppet_collection_for(:foo, '5.5.4') }.to raise_error
|
143
143
|
end
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
|
145
|
+
context 'when the :puppet_agent package is passed in' do
|
146
|
+
context 'given a valid version' do
|
147
|
+
{
|
148
|
+
'1.10.14' => 'pc1',
|
149
|
+
'1.10.x' => 'pc1',
|
150
|
+
'5.3.1' => 'puppet5',
|
151
|
+
'5.3.x' => 'puppet5',
|
152
|
+
'5.99.0' => 'puppet6',
|
153
|
+
'6.1.99-foo' => 'puppet6',
|
154
|
+
'6.99.99' => 'puppet7',
|
155
|
+
'7.0.0' => 'puppet7',
|
156
|
+
}.each do |version, collection|
|
157
|
+
it "returns collection '#{collection}' for version '#{version}'" do
|
158
|
+
expect(subject.puppet_collection_for(:puppet_agent, version)).to eq(collection)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
it "returns the default, latest puppet collection given the version 'latest'" do
|
164
|
+
expect(subject.puppet_collection_for(:puppet_agent, 'latest')).to eq('puppet')
|
165
|
+
end
|
166
|
+
|
167
|
+
context 'given an invalid version' do
|
168
|
+
[nil, '', '0.1.0', '3.8.1', '', 'not-semver', 'not.semver.either'].each do |version|
|
169
|
+
it "returns a nil collection value for version '#{version}'" do
|
170
|
+
expect(subject.puppet_collection_for(:puppet_agent, version)).to be_nil
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
149
174
|
end
|
150
|
-
|
151
|
-
|
175
|
+
|
176
|
+
context 'when the :puppet package is passed-in' do
|
177
|
+
context 'given a valid version' do
|
178
|
+
{
|
179
|
+
'4.9.0' => 'pc1',
|
180
|
+
'4.10.x' => 'pc1',
|
181
|
+
'5.3.1' => 'puppet5',
|
182
|
+
'5.3.x' => 'puppet5',
|
183
|
+
'5.99.0' => 'puppet6',
|
184
|
+
'6.1.99-foo' => 'puppet6',
|
185
|
+
'6.99.99' => 'puppet7',
|
186
|
+
'7.0.0' => 'puppet7',
|
187
|
+
}.each do |version, collection|
|
188
|
+
it "returns collection '#{collection}' for version '#{version}'" do
|
189
|
+
expect(subject.puppet_collection_for(:puppet, version)).to eq(collection)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
it "returns the default, latest puppet collection given the version 'latest'" do
|
195
|
+
expect(subject.puppet_collection_for(:puppet, 'latest')).to eq('puppet')
|
196
|
+
end
|
197
|
+
|
198
|
+
context 'given an invalid version' do
|
199
|
+
[nil, '', '0.1.0', '3.8.1', '', 'not-semver', 'not.semver.either'].each do |version|
|
200
|
+
it "returns a nil collection value for version '#{version}'" do
|
201
|
+
expect(subject.puppet_collection_for(:puppet, version)).to be_nil
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
152
205
|
end
|
153
206
|
end
|
154
|
-
|
155
207
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|