beaker-puppet 1.29.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +28 -7
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +842 -0
- data/CHANGELOG.md +31 -0
- data/Gemfile +5 -20
- data/Rakefile +64 -169
- data/acceptance/config/acceptance-options.rb +3 -3
- data/acceptance/config/gem/acceptance-options.rb +8 -8
- data/acceptance/config/git/acceptance-options.rb +8 -8
- data/acceptance/config/pkg/acceptance-options.rb +7 -7
- data/acceptance/pre_suite/gem/install.rb +6 -6
- data/acceptance/pre_suite/git/install.rb +22 -22
- data/acceptance/pre_suite/pkg/install.rb +3 -3
- data/acceptance/tests/backwards_compatible.rb +6 -7
- data/acceptance/tests/clone_git_repo_on_test.rb +12 -13
- data/acceptance/tests/create_tmpdir_on_test.rb +13 -9
- data/acceptance/tests/install_smoke_test.rb +5 -4
- data/acceptance/tests/stub_host.rb +11 -10
- data/acceptance/tests/web_helpers_test.rb +11 -10
- data/beaker-puppet.gemspec +16 -23
- data/bin/beaker-puppet +2 -4
- data/lib/beaker-puppet/helpers/facter_helpers.rb +9 -7
- data/lib/beaker-puppet/helpers/host_helpers.rb +10 -7
- data/lib/beaker-puppet/helpers/puppet_helpers.rb +151 -160
- data/lib/beaker-puppet/helpers/rake_helpers.rb +1 -1
- data/lib/beaker-puppet/helpers/tk_helpers.rb +22 -28
- data/lib/beaker-puppet/install_utils/aio_defaults.rb +39 -43
- data/lib/beaker-puppet/install_utils/ezbake_utils.rb +34 -42
- data/lib/beaker-puppet/install_utils/foss_defaults.rb +134 -138
- data/lib/beaker-puppet/install_utils/foss_utils.rb +293 -320
- data/lib/beaker-puppet/install_utils/module_utils.rb +58 -70
- data/lib/beaker-puppet/install_utils/puppet5.rb +30 -35
- data/lib/beaker-puppet/install_utils/puppet_utils.rb +58 -68
- data/lib/beaker-puppet/install_utils/windows_utils.rb +34 -36
- data/lib/beaker-puppet/version.rb +1 -1
- data/lib/beaker-puppet/wrappers.rb +13 -14
- data/lib/beaker-puppet.rb +4 -5
- data/setup/aio/010_Install_Puppet_Agent.rb +5 -6
- data/setup/common/000-delete-puppet-when-none.rb +2 -4
- data/setup/common/003_solaris_cert_fix.rb +74 -70
- data/setup/common/005_redhat_subscription_fix.rb +3 -2
- data/setup/common/011_Install_Puppet_Server.rb +7 -9
- data/setup/common/012_Finalize_Installs.rb +5 -5
- data/setup/common/025_StopFirewall.rb +1 -1
- data/setup/common/030_StopSssd.rb +2 -2
- data/setup/common/040_ValidateSignCert.rb +10 -12
- data/setup/common/045_EnsureMasterStarted.rb +2 -2
- data/setup/gem/010_GemInstall.rb +5 -4
- data/setup/git/000_EnvSetup.rb +48 -48
- data/setup/git/010_TestSetup.rb +13 -12
- data/setup/git/020_PuppetUserAndGroup.rb +3 -2
- data/setup/git/060_InstallModules.rb +14 -14
- data/setup/git/070_InstallCACerts.rb +82 -82
- data/spec/beaker-puppet/helpers/facter_helpers_spec.rb +22 -24
- data/spec/beaker-puppet/helpers/host_helpers_spec.rb +10 -6
- data/spec/beaker-puppet/helpers/puppet_helpers_spec.rb +506 -517
- data/spec/beaker-puppet/helpers/tk_helpers_spec.rb +20 -24
- data/spec/beaker-puppet/install_utils/ezbake_utils_spec.rb +86 -90
- data/spec/beaker-puppet/install_utils/foss_utils_spec.rb +636 -599
- data/spec/beaker-puppet/install_utils/module_utils_spec.rb +125 -116
- data/spec/beaker-puppet/install_utils/puppet5_spec.rb +159 -165
- data/spec/beaker-puppet/install_utils/puppet_utils_spec.rb +92 -77
- data/spec/beaker-puppet/install_utils/windows_utils_spec.rb +101 -89
- data/spec/beaker-puppet/wrappers_spec.rb +10 -10
- data/spec/helpers.rb +85 -91
- data/tasks/ci.rake +171 -179
- metadata +33 -62
- data/setup/common/020_InstallCumulusModules.rb +0 -13
- data/setup/common/021_InstallAristaModuleMasters.rb +0 -12
- data/setup/common/022_InstallAristaModuleAgents.rb +0 -13
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
[
|
1
|
+
require 'beaker-puppet/install_utils/windows_utils'
|
2
|
+
%w[aio foss].each do |lib|
|
3
3
|
require "beaker-puppet/install_utils/#{lib}_defaults"
|
4
4
|
end
|
5
|
-
require
|
5
|
+
require 'beaker-puppet/install_utils/puppet_utils'
|
6
6
|
module Beaker
|
7
7
|
module DSL
|
8
8
|
module InstallUtils
|
@@ -23,13 +23,13 @@ module Beaker
|
|
23
23
|
include WindowsUtils
|
24
24
|
|
25
25
|
# The default install path
|
26
|
-
SourcePath
|
26
|
+
SourcePath = '/opt/puppet-git-repos'
|
27
27
|
|
28
28
|
# A regex to know if the uri passed is pointing to a git repo
|
29
|
-
GitURI
|
29
|
+
GitURI = %r{^(git|https?|file)://|^git@|^gitmirror@}
|
30
30
|
|
31
31
|
# Github's ssh signature for cloning via ssh
|
32
|
-
GitHubSig
|
32
|
+
GitHubSig = 'github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
|
33
33
|
|
34
34
|
# Merge given options with our default options in a consistent way
|
35
35
|
# This will remove any nil values so that we always have a set default.
|
@@ -45,17 +45,17 @@ module Beaker
|
|
45
45
|
opts[:nightly_win_download_url] ||= opts[:nightly_builds_url]
|
46
46
|
opts[:nightly_mac_download_url] ||= opts[:nightly_builds_url]
|
47
47
|
|
48
|
-
FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts.reject{|k,v| v.nil?})
|
48
|
+
FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts.reject { |k, v| v.nil? })
|
49
49
|
end
|
50
50
|
|
51
51
|
# lookup project-specific git environment variables
|
52
52
|
# PROJECT_VAR or VAR otherwise return the default
|
53
53
|
#
|
54
54
|
# @!visibility private
|
55
|
-
def lookup_in_env(env_variable_name, project_name=nil, default=nil)
|
56
|
-
env_variable_name = "#{env_variable_name.upcase.gsub('-','_')}"
|
57
|
-
project_specific_name = "#{project_name.upcase.gsub('-','_')}_#{env_variable_name}" if project_name
|
58
|
-
project_name && ENV[project_specific_name] || ENV[env_variable_name] || default
|
55
|
+
def lookup_in_env(env_variable_name, project_name = nil, default = nil)
|
56
|
+
env_variable_name = "#{env_variable_name.upcase.gsub('-', '_')}"
|
57
|
+
project_specific_name = "#{project_name.upcase.gsub('-', '_')}_#{env_variable_name}" if project_name
|
58
|
+
project_name && ENV[project_specific_name] || ENV[env_variable_name] || default # rubocop:disable Style/FetchEnvVar
|
59
59
|
end
|
60
60
|
|
61
61
|
# @return [Boolean] Whether Puppet's internal builds are accessible from all the SUTs
|
@@ -76,7 +76,7 @@ module Beaker
|
|
76
76
|
return true if host.host_hash[:template] == 'redhat-8-arm64' && host.hostname =~ /.puppet.net$/
|
77
77
|
|
78
78
|
result = on(host, %(curl --location -fI "#{url}"), accept_all_exit_codes: true)
|
79
|
-
|
79
|
+
result.exit_code.zero?
|
80
80
|
end
|
81
81
|
|
82
82
|
# @param [String] project_name
|
@@ -87,7 +87,7 @@ module Beaker
|
|
87
87
|
# @return [String] Returns a git-usable url
|
88
88
|
#
|
89
89
|
# TODO: enable other protocols, clarify, http://git-scm.com/book/ch4-1.html
|
90
|
-
def build_git_url(project_name, git_fork = nil, git_server = nil, git_protocol='https')
|
90
|
+
def build_git_url(project_name, git_fork = nil, git_server = nil, git_protocol = 'https')
|
91
91
|
git_fork ||= lookup_in_env('FORK', project_name, 'puppetlabs')
|
92
92
|
git_server ||= lookup_in_env('SERVER', project_name, 'github.com')
|
93
93
|
|
@@ -98,10 +98,10 @@ module Beaker
|
|
98
98
|
git_protocol = 'https://'
|
99
99
|
end
|
100
100
|
|
101
|
-
repo =
|
102
|
-
|
101
|
+
repo = git_server == 'github.com' ? "#{git_fork}/#{project_name}.git" : "#{git_fork}-#{project_name}.git"
|
102
|
+
git_protocol == 'git@' ? "#{git_protocol}#{git_server}:#{repo}" : "#{git_protocol}#{git_server}/#{repo}"
|
103
103
|
end
|
104
|
-
|
104
|
+
alias build_giturl build_git_url
|
105
105
|
|
106
106
|
# @param [String] uri A uri in the format of <git uri>#<revision>
|
107
107
|
# the `git://`, `http://`, `https://`, and ssh
|
@@ -121,14 +121,14 @@ module Beaker
|
|
121
121
|
# name, repository path, and revision
|
122
122
|
# (defaults to HEAD)
|
123
123
|
#
|
124
|
-
def extract_repo_info_from
|
124
|
+
def extract_repo_info_from(uri)
|
125
125
|
require 'pathname'
|
126
126
|
project = {}
|
127
127
|
repo, rev = uri.split('#', 2)
|
128
128
|
project[:name] = Pathname.new(repo).basename('.git').to_s
|
129
129
|
project[:path] = repo
|
130
130
|
project[:rev] = rev || 'HEAD'
|
131
|
-
|
131
|
+
project
|
132
132
|
end
|
133
133
|
|
134
134
|
# Takes an array of package info hashes (like that returned from
|
@@ -136,8 +136,8 @@ module Beaker
|
|
136
136
|
# packages so that puppet's dependencies will be installed first.
|
137
137
|
#
|
138
138
|
# @!visibility private
|
139
|
-
def order_packages
|
140
|
-
puppet = packages_array.select {|e| e[:name] == 'puppet' }
|
139
|
+
def order_packages(packages_array)
|
140
|
+
puppet = packages_array.select { |e| e[:name] == 'puppet' }
|
141
141
|
puppet_depends_on = packages_array.select do |e|
|
142
142
|
e[:name] == 'hiera' or e[:name] == 'facter'
|
143
143
|
end
|
@@ -163,12 +163,12 @@ module Beaker
|
|
163
163
|
# @note This requires the helper methods:
|
164
164
|
# * {Beaker::DSL::Helpers#on}
|
165
165
|
#
|
166
|
-
def find_git_repo_versions
|
166
|
+
def find_git_repo_versions(host, path, repository)
|
167
167
|
logger.notify("\n * Grab version for #{repository[:name]}")
|
168
168
|
|
169
169
|
version = {}
|
170
170
|
on host, "cd #{path}/#{repository[:name]} && " +
|
171
|
-
|
171
|
+
'git describe || true' do
|
172
172
|
version[repository[:name]] = stdout.chomp
|
173
173
|
end
|
174
174
|
|
@@ -185,8 +185,8 @@ module Beaker
|
|
185
185
|
# @note This requires the helper methods:
|
186
186
|
# * {Beaker::DSL::Helpers#on}
|
187
187
|
#
|
188
|
-
def clone_git_repo_on
|
189
|
-
opts = {:
|
188
|
+
def clone_git_repo_on(host, path, repository, opts = {})
|
189
|
+
opts = { accept_all_exit_codes: true }.merge(opts)
|
190
190
|
name = repository[:name]
|
191
191
|
repo = repository[:path]
|
192
192
|
rev = repository[:rev]
|
@@ -194,14 +194,10 @@ module Beaker
|
|
194
194
|
depth_branch = repository[:depth_branch]
|
195
195
|
target = "#{path}/#{name}"
|
196
196
|
|
197
|
-
if
|
198
|
-
depth_branch = rev
|
199
|
-
end
|
197
|
+
depth_branch = rev if depth_branch.nil?
|
200
198
|
|
201
199
|
clone_cmd = "git clone #{repo} #{target}"
|
202
|
-
if
|
203
|
-
clone_cmd = "git clone --branch #{depth_branch} --depth #{depth} #{repo} #{target}"
|
204
|
-
end
|
200
|
+
clone_cmd = "git clone --branch #{depth_branch} --depth #{depth} #{repo} #{target}" if depth
|
205
201
|
|
206
202
|
logger.notify("\n * Clone #{repo} if needed")
|
207
203
|
|
@@ -210,44 +206,44 @@ module Beaker
|
|
210
206
|
|
211
207
|
logger.notify("\n * Update #{name} and check out revision #{rev}")
|
212
208
|
commands = ["cd #{target}",
|
213
|
-
|
209
|
+
'remote rm origin',
|
214
210
|
"remote add origin #{repo}",
|
215
|
-
|
216
|
-
|
217
|
-
"checkout -f #{rev}"]
|
218
|
-
on host, commands.join(
|
211
|
+
'fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/*',
|
212
|
+
'clean -fdx',
|
213
|
+
"checkout -f #{rev}",]
|
214
|
+
on host, commands.join(' && git '), opts
|
219
215
|
end
|
220
216
|
|
221
217
|
# @see #find_git_repo_versions
|
222
218
|
# @note This assumes the target repository application
|
223
219
|
# can be installed via an install.rb ruby script.
|
224
|
-
def install_from_git_on
|
225
|
-
opts = {:
|
220
|
+
def install_from_git_on(host, path, repository, opts = {})
|
221
|
+
opts = { accept_all_exit_codes: true }.merge(opts)
|
226
222
|
clone_git_repo_on host, path, repository, opts
|
227
|
-
name
|
223
|
+
name = repository[:name]
|
228
224
|
logger.notify("\n * Install #{name} on the system")
|
229
225
|
# The solaris ruby IPS package has bindir set to /usr/ruby/1.8/bin.
|
230
226
|
# However, this is not the path to which we want to deliver our
|
231
227
|
# binaries. So if we are using solaris, we have to pass the bin and
|
232
228
|
# sbin directories to the install.rb
|
233
|
-
target
|
229
|
+
target = "#{path}/#{name}"
|
234
230
|
install_opts = ''
|
235
231
|
install_opts = '--bindir=/usr/bin --sbindir=/usr/sbin' if host['platform'].include? 'solaris'
|
236
232
|
|
237
233
|
on host, "cd #{target} && " +
|
238
|
-
|
234
|
+
'if [ -f install.rb ]; then ' +
|
239
235
|
"ruby ./install.rb #{install_opts}; " +
|
240
|
-
|
236
|
+
'else true; fi', opts
|
241
237
|
end
|
242
|
-
|
238
|
+
alias install_from_git install_from_git_on
|
243
239
|
|
244
240
|
# @deprecated Use {#install_puppet_on} instead.
|
245
241
|
def install_puppet(opts = {})
|
246
|
-
#send in the global hosts!
|
242
|
+
# send in the global hosts!
|
247
243
|
install_puppet_on(hosts, opts)
|
248
244
|
end
|
249
245
|
|
250
|
-
#Install FOSS based on specified hosts using provided options
|
246
|
+
# Install FOSS based on specified hosts using provided options
|
251
247
|
# @example will install puppet 3.6.1 from native puppetlabs provided packages wherever possible and will fail over to gem installation when impossible
|
252
248
|
# install_puppet_on(hosts, {
|
253
249
|
# :version => '3.6.1',
|
@@ -275,7 +271,7 @@ module Beaker
|
|
275
271
|
# install_puppet_on(hosts)
|
276
272
|
#
|
277
273
|
# @note This will attempt to add a repository for apt.puppetlabs.com on
|
278
|
-
# Debian
|
274
|
+
# Debian or Ubuntu machines, or yum.puppetlabs.com on EL or Fedora
|
279
275
|
# machines, then install the package 'puppet' or 'puppet-agent'.
|
280
276
|
#
|
281
277
|
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
@@ -294,7 +290,7 @@ module Beaker
|
|
294
290
|
opts = sanitize_opts(opts)
|
295
291
|
|
296
292
|
# If version isn't specified assume the latest in the 3.x series
|
297
|
-
if opts[:version] and
|
293
|
+
if opts[:version] and !version_is_less(opts[:version], '4.0.0')
|
298
294
|
# backwards compatability
|
299
295
|
opts[:puppet_agent_version] ||= opts[:version]
|
300
296
|
install_puppet_agent_on(hosts, opts)
|
@@ -302,12 +298,12 @@ module Beaker
|
|
302
298
|
# Use option specified in the method call, otherwise check whether the global
|
303
299
|
# run_in_parallel option includes install
|
304
300
|
run_in_parallel = run_in_parallel? opts, @options, 'install'
|
305
|
-
block_on hosts, { :
|
301
|
+
block_on hosts, { run_in_parallel: run_in_parallel } do |host|
|
306
302
|
if host['platform'] =~ /(el|fedora)-(\d+)/
|
307
|
-
family =
|
308
|
-
relver =
|
309
|
-
install_puppet_from_rpm_on(host, opts.merge(:
|
310
|
-
elsif host['platform'] =~ /(ubuntu|debian|
|
303
|
+
family = ::Regexp.last_match(1)
|
304
|
+
relver = ::Regexp.last_match(2)
|
305
|
+
install_puppet_from_rpm_on(host, opts.merge(release: relver, family: family))
|
306
|
+
elsif host['platform'] =~ /(ubuntu|debian|huaweios)/
|
311
307
|
install_puppet_from_deb_on(host, opts)
|
312
308
|
elsif host['platform'] =~ /windows/
|
313
309
|
relver = opts[:version]
|
@@ -321,12 +317,13 @@ module Beaker
|
|
321
317
|
elsif host['platform'] =~ /archlinux/
|
322
318
|
install_puppet_from_pacman_on(host, opts)
|
323
319
|
else
|
324
|
-
|
325
|
-
opts[:version] ||= '~> 3.x'
|
326
|
-
install_puppet_from_gem_on(host, opts)
|
327
|
-
else
|
320
|
+
unless opts[:default_action] == 'gem_install'
|
328
321
|
raise "install_puppet() called for unsupported platform '#{host['platform']}' on '#{host.name}'"
|
329
322
|
end
|
323
|
+
|
324
|
+
opts[:version] ||= '~> 3.x'
|
325
|
+
install_puppet_from_gem_on(host, opts)
|
326
|
+
|
330
327
|
end
|
331
328
|
|
332
329
|
host[:version] = opts[:version]
|
@@ -334,7 +331,7 @@ module Beaker
|
|
334
331
|
# Certain install paths may not create the config dirs/files needed
|
335
332
|
host.mkdir_p host['puppetpath'] unless host[:type] =~ /aio/
|
336
333
|
|
337
|
-
if (
|
334
|
+
if (host['platform'] =~ /windows/) and !host.is_cygwin?
|
338
335
|
# Do nothing
|
339
336
|
else
|
340
337
|
on host, "echo '' >> #{host.puppet['hiera_config']}"
|
@@ -357,7 +354,7 @@ module Beaker
|
|
357
354
|
# install_puppet_agent_on(hosts)
|
358
355
|
#
|
359
356
|
# @note This will attempt to add a repository for apt.puppetlabs.com on
|
360
|
-
# Debian
|
357
|
+
# Debian or Ubuntu machines, or yum.puppetlabs.com on EL or Fedora
|
361
358
|
# machines, then install the package 'puppet-agent'.
|
362
359
|
#
|
363
360
|
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
@@ -377,14 +374,14 @@ module Beaker
|
|
377
374
|
# @raise [FailTest] When error occurs during the actual installation process
|
378
375
|
def install_puppet_agent_on(hosts, opts = {})
|
379
376
|
opts = sanitize_opts(opts)
|
380
|
-
opts[:puppet_agent_version] ||= opts[:version] #backwards compatability with old parameter name
|
377
|
+
opts[:puppet_agent_version] ||= opts[:version] # backwards compatability with old parameter name
|
381
378
|
opts[:puppet_collection] ||= puppet_collection_for(:puppet_agent, opts[:puppet_agent_version]) || 'pc1'
|
382
379
|
|
383
380
|
# the collection names are case sensitive
|
384
381
|
opts[:puppet_collection] = opts[:puppet_collection].downcase
|
385
382
|
|
386
383
|
run_in_parallel = run_in_parallel? opts, @options, 'install'
|
387
|
-
block_on hosts, { :
|
384
|
+
block_on hosts, { run_in_parallel: run_in_parallel } do |host|
|
388
385
|
# AIO refers to FOSS agents that contain puppet 4+, that is, puppet-agent packages
|
389
386
|
# in the 1.x series, or the 5.x series, or later. Previous versions are not supported,
|
390
387
|
# so 'aio' is the only role that makes sense here.
|
@@ -392,7 +389,9 @@ module Beaker
|
|
392
389
|
package_name = nil
|
393
390
|
|
394
391
|
# If inside the Puppet VPN, install from development builds.
|
395
|
-
if opts[:puppet_agent_version] && opts[:puppet_agent_version] != 'latest' && dev_builds_accessible_on?(
|
392
|
+
if opts[:puppet_agent_version] && opts[:puppet_agent_version] != 'latest' && dev_builds_accessible_on?(
|
393
|
+
host, opts[:dev_builds_url]
|
394
|
+
)
|
396
395
|
install_puppet_agent_from_dev_builds_on(host, opts[:puppet_agent_version])
|
397
396
|
else
|
398
397
|
if opts[:puppet_agent_version] == 'latest'
|
@@ -410,13 +409,17 @@ module Beaker
|
|
410
409
|
when /el-|redhat|fedora|sles|centos|cisco_/
|
411
410
|
package_name = 'puppet-agent'
|
412
411
|
package_name << "-#{opts[:puppet_agent_version]}" if opts[:puppet_agent_version]
|
413
|
-
when /debian|ubuntu|
|
412
|
+
when /debian|ubuntu|huaweios/
|
414
413
|
package_name = 'puppet-agent'
|
415
|
-
|
414
|
+
if opts[:puppet_agent_version]
|
415
|
+
package_name << "=#{opts[:puppet_agent_version]}-1#{host['platform'].codename}"
|
416
|
+
end
|
416
417
|
when /windows/
|
417
418
|
install_puppet_agent_from_msi_on(host, opts)
|
418
419
|
when /osx/
|
419
420
|
install_puppet_agent_from_dmg_on(host, opts)
|
421
|
+
when /freebsd/
|
422
|
+
install_puppet_from_freebsd_ports_on(host, opts)
|
420
423
|
when /archlinux/
|
421
424
|
install_puppet_from_pacman_on(host, opts)
|
422
425
|
else
|
@@ -425,23 +428,23 @@ module Beaker
|
|
425
428
|
install_puppet_from_gem_on(host, opts)
|
426
429
|
on host, "echo '' >> #{host.puppet['hiera_config']}"
|
427
430
|
else
|
428
|
-
raise
|
431
|
+
raise 'install_puppet_agent_on() called for unsupported ' +
|
429
432
|
"platform '#{host['platform']}' on '#{host.name}'"
|
430
433
|
end
|
431
434
|
end
|
432
435
|
|
433
436
|
if package_name
|
434
|
-
install_puppetlabs_release_repo(
|
435
|
-
host.install_package(
|
437
|
+
install_puppetlabs_release_repo(host, opts[:puppet_collection], opts)
|
438
|
+
host.install_package(package_name)
|
436
439
|
end
|
437
440
|
end
|
438
441
|
end
|
439
442
|
end
|
440
443
|
|
441
444
|
# @deprecated Use {#configure_puppet_on} instead.
|
442
|
-
def configure_puppet(opts={})
|
445
|
+
def configure_puppet(opts = {})
|
443
446
|
hosts.each do |host|
|
444
|
-
configure_puppet_on(host,opts)
|
447
|
+
configure_puppet_on(host, opts)
|
445
448
|
end
|
446
449
|
end
|
447
450
|
|
@@ -472,14 +475,14 @@ module Beaker
|
|
472
475
|
# @return nil
|
473
476
|
def configure_puppet_on(hosts, opts = {})
|
474
477
|
puppet_conf_text = ''
|
475
|
-
opts.each do |section,options|
|
478
|
+
opts.each do |section, options|
|
476
479
|
puppet_conf_text << "[#{section}]\n"
|
477
|
-
options.each do |option,value|
|
480
|
+
options.each do |option, value|
|
478
481
|
puppet_conf_text << "#{option}=#{value}\n"
|
479
482
|
end
|
480
483
|
puppet_conf_text << "\n"
|
481
484
|
end
|
482
|
-
logger.debug(
|
485
|
+
logger.debug("setting config '#{puppet_conf_text}' on hosts #{hosts}")
|
483
486
|
block_on hosts, opts do |host|
|
484
487
|
puppet_conf_path = host.puppet['config']
|
485
488
|
create_remote_file(host, puppet_conf_path, puppet_conf_text)
|
@@ -499,30 +502,26 @@ module Beaker
|
|
499
502
|
#
|
500
503
|
# @return nil
|
501
504
|
# @api private
|
502
|
-
def install_puppet_from_rpm_on(
|
505
|
+
def install_puppet_from_rpm_on(hosts, opts)
|
503
506
|
block_on hosts do |host|
|
504
507
|
if opts[:puppet_collection] && opts[:puppet_collection].match(/puppet\d*/)
|
505
|
-
install_puppetlabs_release_repo(host,opts[:puppet_collection],opts)
|
508
|
+
install_puppetlabs_release_repo(host, opts[:puppet_collection], opts)
|
506
509
|
elsif host[:type] == 'aio'
|
507
|
-
install_puppetlabs_release_repo(host,'pc1',opts)
|
510
|
+
install_puppetlabs_release_repo(host, 'pc1', opts)
|
508
511
|
else
|
509
|
-
install_puppetlabs_release_repo(host,nil,opts)
|
512
|
+
install_puppetlabs_release_repo(host, nil, opts)
|
510
513
|
end
|
511
514
|
|
512
|
-
if opts[:facter_version]
|
513
|
-
host.install_package("facter-#{opts[:facter_version]}")
|
514
|
-
end
|
515
|
+
host.install_package("facter-#{opts[:facter_version]}") if opts[:facter_version]
|
515
516
|
|
516
|
-
if opts[:hiera_version]
|
517
|
-
host.install_package("hiera-#{opts[:hiera_version]}")
|
518
|
-
end
|
517
|
+
host.install_package("hiera-#{opts[:hiera_version]}") if opts[:hiera_version]
|
519
518
|
|
520
519
|
puppet_pkg = opts[:version] ? "puppet-#{opts[:version]}" : 'puppet'
|
521
520
|
host.install_package("#{puppet_pkg}")
|
522
|
-
configure_type_defaults_on(
|
521
|
+
configure_type_defaults_on(host)
|
523
522
|
end
|
524
523
|
end
|
525
|
-
|
524
|
+
alias install_puppet_from_rpm install_puppet_from_rpm_on
|
526
525
|
|
527
526
|
# Installs Puppet and dependencies from deb on provided host(s).
|
528
527
|
#
|
@@ -535,17 +534,13 @@ module Beaker
|
|
535
534
|
#
|
536
535
|
# @return nil
|
537
536
|
# @api private
|
538
|
-
def install_puppet_from_deb_on(
|
537
|
+
def install_puppet_from_deb_on(hosts, opts)
|
539
538
|
block_on hosts do |host|
|
540
539
|
install_puppetlabs_release_repo(host)
|
541
540
|
|
542
|
-
if opts[:facter_version]
|
543
|
-
host.install_package("facter=#{opts[:facter_version]}-1puppetlabs1")
|
544
|
-
end
|
541
|
+
host.install_package("facter=#{opts[:facter_version]}-1puppetlabs1") if opts[:facter_version]
|
545
542
|
|
546
|
-
if opts[:hiera_version]
|
547
|
-
host.install_package("hiera=#{opts[:hiera_version]}-1puppetlabs1")
|
548
|
-
end
|
543
|
+
host.install_package("hiera=#{opts[:hiera_version]}-1puppetlabs1") if opts[:hiera_version]
|
549
544
|
|
550
545
|
if opts[:version]
|
551
546
|
host.install_package("puppet-common=#{opts[:version]}-1puppetlabs1")
|
@@ -553,10 +548,10 @@ module Beaker
|
|
553
548
|
else
|
554
549
|
host.install_package('puppet')
|
555
550
|
end
|
556
|
-
configure_type_defaults_on(
|
551
|
+
configure_type_defaults_on(host)
|
557
552
|
end
|
558
553
|
end
|
559
|
-
|
554
|
+
alias install_puppet_from_deb install_puppet_from_deb_on
|
560
555
|
|
561
556
|
# Installs Puppet and dependencies from msi on provided host(s).
|
562
557
|
#
|
@@ -570,15 +565,15 @@ module Beaker
|
|
570
565
|
#
|
571
566
|
# @note on windows, the +:ruby_arch+ host parameter can determine in addition
|
572
567
|
# to other settings whether the 32 or 64bit install is used
|
573
|
-
def install_puppet_from_msi_on(
|
568
|
+
def install_puppet_from_msi_on(hosts, opts)
|
574
569
|
block_on hosts do |host|
|
575
570
|
version = opts[:version]
|
576
571
|
|
577
572
|
if version && !version_is_less(version, '4.0.0')
|
578
573
|
if opts[:puppet_agent_version].nil?
|
579
|
-
raise
|
580
|
-
|
581
|
-
|
574
|
+
raise 'You must specify the version of puppet agent you ' +
|
575
|
+
'want to install if you want to install Puppet 4.0 ' +
|
576
|
+
'or greater on Windows'
|
582
577
|
end
|
583
578
|
|
584
579
|
opts[:version] = opts[:puppet_agent_version]
|
@@ -589,10 +584,10 @@ module Beaker
|
|
589
584
|
install_a_puppet_msi_on(host, opts)
|
590
585
|
|
591
586
|
end
|
592
|
-
configure_type_defaults_on(
|
587
|
+
configure_type_defaults_on(host)
|
593
588
|
end
|
594
589
|
end
|
595
|
-
|
590
|
+
alias install_puppet_from_msi install_puppet_from_msi_on
|
596
591
|
|
597
592
|
# @api private
|
598
593
|
def compute_puppet_msi_name(host, opts)
|
@@ -601,12 +596,12 @@ module Beaker
|
|
601
596
|
less_than_3_dot_7 = version && version_is_less(version, '3.7')
|
602
597
|
|
603
598
|
# If there's no version declared, install the latest in the 3.x series
|
604
|
-
if
|
605
|
-
if !host.is_x86_64? || install_32
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
599
|
+
if !version
|
600
|
+
host['dist'] = if !host.is_x86_64? || install_32
|
601
|
+
'puppet-latest'
|
602
|
+
else
|
603
|
+
'puppet-x64-latest'
|
604
|
+
end
|
610
605
|
|
611
606
|
# Install Puppet 3.x with the x86 installer if:
|
612
607
|
# - we are on puppet < 3.7, or
|
@@ -614,11 +609,11 @@ module Beaker
|
|
614
609
|
# - we have install_32 set on host or globally
|
615
610
|
# Install Puppet 3.x with the x64 installer if:
|
616
611
|
# - we are otherwise trying to install Puppet 3.x on a x64 host
|
617
|
-
elsif less_than_3_dot_7 or
|
612
|
+
elsif less_than_3_dot_7 or !host.is_x86_64? or install_32
|
618
613
|
host['dist'] = "puppet-#{version}"
|
619
614
|
|
620
615
|
elsif host.is_x86_64?
|
621
|
-
|
616
|
+
host['dist'] = "puppet-#{version}-x64"
|
622
617
|
|
623
618
|
else
|
624
619
|
raise "I don't understand how to install Puppet version: #{version}"
|
@@ -637,18 +632,17 @@ module Beaker
|
|
637
632
|
# to other settings whether the 32 or 64bit install is used
|
638
633
|
def install_puppet_agent_from_msi_on(hosts, opts)
|
639
634
|
block_on hosts do |host|
|
640
|
-
|
641
|
-
add_role(host, 'aio') #we are installing agent, so we want aio role
|
635
|
+
add_role(host, 'aio') # we are installing agent, so we want aio role
|
642
636
|
is_config_32 = true == (host['ruby_arch'] == 'x86') || host['install_32'] || opts['install_32']
|
643
637
|
should_install_64bit = host.is_x86_64? && !is_config_32
|
644
638
|
arch = should_install_64bit ? 'x64' : 'x86'
|
645
639
|
|
646
640
|
# If we don't specify a version install the latest MSI for puppet-agent
|
647
|
-
if opts[:puppet_agent_version]
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
641
|
+
host['dist'] = if opts[:puppet_agent_version]
|
642
|
+
"puppet-agent-#{opts[:puppet_agent_version]}-#{arch}"
|
643
|
+
else
|
644
|
+
"puppet-agent-#{arch}-latest"
|
645
|
+
end
|
652
646
|
|
653
647
|
install_a_puppet_msi_on(host, opts)
|
654
648
|
end
|
@@ -666,9 +660,8 @@ module Beaker
|
|
666
660
|
else
|
667
661
|
link = "#{opts[:win_download_url]}/#{host['dist']}.msi"
|
668
662
|
end
|
669
|
-
|
670
|
-
|
671
|
-
end
|
663
|
+
raise "Puppet MSI at #{link} does not exist!" unless link_exists?(link)
|
664
|
+
|
672
665
|
link
|
673
666
|
end
|
674
667
|
|
@@ -683,20 +676,21 @@ module Beaker
|
|
683
676
|
proxy = opts[:package_proxy] ? "-x #{opts[:package_proxy]} " : ''
|
684
677
|
on host, "curl #{proxy}--location --output \"#{msi_download_path}\" --remote-name #{link}"
|
685
678
|
|
686
|
-
#Because the msi installer doesn't add Puppet to the environment path
|
687
|
-
#Add both potential paths for simplicity
|
688
|
-
#NOTE - this is unnecessary if the host has been correctly identified as 'foss' during set up
|
689
|
-
puppetbin_path = "
|
690
|
-
on host, %
|
679
|
+
# Because the msi installer doesn't add Puppet to the environment path
|
680
|
+
# Add both potential paths for simplicity
|
681
|
+
# NOTE - this is unnecessary if the host has been correctly identified as 'foss' during set up
|
682
|
+
puppetbin_path = '"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin":"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin"'
|
683
|
+
on host, %( echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc )
|
691
684
|
else
|
692
685
|
webclient_proxy = opts[:package_proxy] ? "$webclient.Proxy = New-Object System.Net.WebProxy('#{opts[:package_proxy]}',$true); " : ''
|
693
|
-
on host,
|
686
|
+
on host,
|
687
|
+
powershell("$webclient = New-Object System.Net.WebClient; #{webclient_proxy}$webclient.DownloadFile('#{link}','#{msi_download_path}')")
|
694
688
|
end
|
695
689
|
|
696
|
-
opts = { :
|
690
|
+
opts = { debug: host[:pe_debug] || opts[:pe_debug] }
|
697
691
|
install_msi_on(host, msi_download_path, {}, opts)
|
698
692
|
|
699
|
-
configure_type_defaults_on(
|
693
|
+
configure_type_defaults_on(host)
|
700
694
|
|
701
695
|
host.mkdir_p host['distmoduledir'] unless host.is_cygwin?
|
702
696
|
end
|
@@ -711,21 +705,17 @@ module Beaker
|
|
711
705
|
#
|
712
706
|
# @return nil
|
713
707
|
# @api private
|
714
|
-
def install_puppet_from_freebsd_ports_on(
|
715
|
-
if
|
708
|
+
def install_puppet_from_freebsd_ports_on(hosts, opts)
|
709
|
+
if opts[:version]
|
716
710
|
logger.warn "If you wish to choose a specific Puppet version, use `install_puppet_from_gem_on('~> 3.*')`"
|
717
711
|
end
|
718
712
|
|
719
713
|
block_on hosts do |host|
|
720
|
-
|
721
|
-
|
722
|
-
else
|
723
|
-
host.install_package("sysutils/puppet")
|
724
|
-
end
|
714
|
+
host.install_package('sysutils/puppet7')
|
715
|
+
configure_type_defaults_on(host)
|
725
716
|
end
|
726
|
-
|
727
717
|
end
|
728
|
-
|
718
|
+
alias install_puppet_from_freebsd_ports install_puppet_from_freebsd_ports_on
|
729
719
|
|
730
720
|
# Installs Puppet and dependencies from dmg on provided host(s).
|
731
721
|
#
|
@@ -740,14 +730,14 @@ module Beaker
|
|
740
730
|
#
|
741
731
|
# @return nil
|
742
732
|
# @api private
|
743
|
-
def install_puppet_from_dmg_on(
|
733
|
+
def install_puppet_from_dmg_on(hosts, opts)
|
744
734
|
block_on hosts do |host|
|
745
735
|
# install puppet-agent if puppet version > 4.0 OR not puppet version is provided
|
746
736
|
if (opts[:version] && !version_is_less(opts[:version], '4.0.0')) || !opts[:version]
|
747
737
|
if opts[:puppet_agent_version].nil?
|
748
|
-
raise
|
749
|
-
|
750
|
-
|
738
|
+
raise 'You must specify the version of puppet-agent you ' +
|
739
|
+
'want to install if you want to install Puppet 4.0 ' +
|
740
|
+
'or greater on OSX'
|
751
741
|
end
|
752
742
|
|
753
743
|
install_puppet_agent_from_dmg_on(host, opts)
|
@@ -757,9 +747,9 @@ module Beaker
|
|
757
747
|
facter_ver = opts[:facter_version] || 'latest'
|
758
748
|
hiera_ver = opts[:hiera_version] || 'latest'
|
759
749
|
|
760
|
-
|
761
|
-
|
762
|
-
|
750
|
+
raise "You need to specify versions for OSX host\n eg. install_puppet({:version => '3.6.2',:facter_version => '2.1.0',:hiera_version => '1.3.4',})" if [
|
751
|
+
puppet_ver, facter_ver, hiera_ver,
|
752
|
+
].include?(nil)
|
763
753
|
|
764
754
|
on host, "curl --location --remote-name #{opts[:mac_download_url]}/puppet-#{puppet_ver}.dmg"
|
765
755
|
on host, "curl --location --remote-name #{opts[:mac_download_url]}/facter-#{facter_ver}.dmg"
|
@@ -769,11 +759,11 @@ module Beaker
|
|
769
759
|
host.install_package("facter-#{facter_ver}")
|
770
760
|
host.install_package("hiera-#{hiera_ver}")
|
771
761
|
|
772
|
-
configure_type_defaults_on(
|
762
|
+
configure_type_defaults_on(host)
|
773
763
|
end
|
774
764
|
end
|
775
765
|
end
|
776
|
-
|
766
|
+
alias install_puppet_from_dmg install_puppet_from_dmg_on
|
777
767
|
|
778
768
|
# Installs puppet-agent and dependencies from dmg on provided host(s).
|
779
769
|
#
|
@@ -790,8 +780,7 @@ module Beaker
|
|
790
780
|
opts[:puppet_collection] ||= 'PC1'
|
791
781
|
opts[:puppet_collection] = opts[:puppet_collection].upcase if opts[:puppet_collection].match(/pc1/i)
|
792
782
|
block_on hosts do |host|
|
793
|
-
|
794
|
-
add_role(host, 'aio') #we are installing agent, so we want aio role
|
783
|
+
add_role(host, 'aio') # we are installing agent, so we want aio role
|
795
784
|
|
796
785
|
variant, version, arch, codename = host['platform'].to_array
|
797
786
|
|
@@ -809,9 +798,7 @@ module Beaker
|
|
809
798
|
latest = get_latest_puppet_agent_build_from_url(download_url)
|
810
799
|
|
811
800
|
agent_version = opts[:puppet_agent_version] || latest
|
812
|
-
unless agent_version.length > 0
|
813
|
-
raise "no puppet-agent version specified or found on at #{download_url}"
|
814
|
-
end
|
801
|
+
raise "no puppet-agent version specified or found on at #{download_url}" unless agent_version.length > 0
|
815
802
|
|
816
803
|
pkg_name = "puppet-agent-#{agent_version}*"
|
817
804
|
dmg_name = "puppet-agent-#{agent_version}-1.osx#{version}.dmg"
|
@@ -819,7 +806,7 @@ module Beaker
|
|
819
806
|
|
820
807
|
host.install_package(pkg_name)
|
821
808
|
|
822
|
-
configure_type_defaults_on(
|
809
|
+
configure_type_defaults_on(host)
|
823
810
|
end
|
824
811
|
end
|
825
812
|
|
@@ -842,28 +829,27 @@ module Beaker
|
|
842
829
|
# Redirect following
|
843
830
|
while response.is_a?(Net::HTTPRedirection) && counter < 15
|
844
831
|
response = Net::HTTP.get_response(URI.parse(Net::HTTP.get_response(URI(full_url))['location']))
|
845
|
-
counter
|
832
|
+
counter += 1
|
846
833
|
end
|
847
834
|
|
848
|
-
|
835
|
+
unless response.is_a?(Net::HTTPSuccess)
|
836
|
+
raise "The URL for puppet-agent download, #{response.uri}, returned #{response.message} with #{response.code}"
|
837
|
+
end
|
849
838
|
|
850
839
|
document = Oga.parse_html(response.body)
|
851
840
|
agents = document.xpath('//a[contains(@href, "puppet-agent")]')
|
852
841
|
|
853
842
|
latest_match = agents.shift.attributes[0].value
|
854
|
-
while (latest_match =~ /puppet-agent-\d(.*)/).nil?
|
855
|
-
latest_match = agents.shift.attributes[0].value
|
856
|
-
end
|
843
|
+
latest_match = agents.shift.attributes[0].value while (latest_match =~ /puppet-agent-\d(.*)/).nil?
|
857
844
|
|
858
|
-
re
|
845
|
+
re = /puppet-agent-(.*)-/
|
859
846
|
latest_match = latest_match.match re
|
860
847
|
|
861
848
|
if latest_match
|
862
|
-
|
849
|
+
latest_match[1]
|
863
850
|
else
|
864
|
-
|
851
|
+
''
|
865
852
|
end
|
866
|
-
return latest
|
867
853
|
end
|
868
854
|
|
869
855
|
# Installs Puppet and dependencies from OpenBSD packages
|
@@ -875,7 +861,7 @@ module Beaker
|
|
875
861
|
# @return nil
|
876
862
|
# @api private
|
877
863
|
def install_puppet_from_openbsd_packages_on(hosts, opts)
|
878
|
-
if
|
864
|
+
if opts[:version]
|
879
865
|
logger.warn "If you wish to choose a specific Puppet version, use `install_puppet_from_gem_on('~> 3.*')`"
|
880
866
|
end
|
881
867
|
|
@@ -895,7 +881,7 @@ module Beaker
|
|
895
881
|
# @return nil
|
896
882
|
# @api private
|
897
883
|
def install_puppet_from_pacman_on(hosts, opts)
|
898
|
-
if
|
884
|
+
if opts[:version]
|
899
885
|
# Arch is rolling release, only the latest package versions are supported
|
900
886
|
logger.warn "If you wish to choose a specific Puppet version, use `install_puppet_from_gem_on('~> 3.*')`"
|
901
887
|
end
|
@@ -919,7 +905,7 @@ module Beaker
|
|
919
905
|
# @return nil
|
920
906
|
# @raise [StandardError] if gem does not exist on target host
|
921
907
|
# @api private
|
922
|
-
def install_puppet_from_gem_on(
|
908
|
+
def install_puppet_from_gem_on(hosts, opts)
|
923
909
|
block_on hosts do |host|
|
924
910
|
# There are a lot of special things to do for Solaris and Solaris 10.
|
925
911
|
# This is easier than checking host['platform'] every time.
|
@@ -928,23 +914,19 @@ module Beaker
|
|
928
914
|
|
929
915
|
# Hosts may be provisioned with csw but pkgutil won't be in the
|
930
916
|
# PATH by default to avoid changing the behavior for Puppet's tests
|
931
|
-
if is_solaris10
|
932
|
-
on host, 'ln -s /opt/csw/bin/pkgutil /usr/bin/pkgutil'
|
933
|
-
end
|
917
|
+
on host, 'ln -s /opt/csw/bin/pkgutil /usr/bin/pkgutil' if is_solaris10
|
934
918
|
|
935
919
|
# Solaris doesn't necessarily have this, but gem needs it
|
936
|
-
if is_solaris
|
937
|
-
on host, 'mkdir -p /var/lib'
|
938
|
-
end
|
920
|
+
on host, 'mkdir -p /var/lib' if is_solaris
|
939
921
|
|
940
|
-
unless host.check_for_command(
|
922
|
+
unless host.check_for_command('gem')
|
941
923
|
gempkg = case host['platform']
|
942
924
|
when /solaris-11/ then 'ruby-18'
|
943
925
|
when /ubuntu-14/ then 'ruby'
|
944
|
-
when /solaris-10|ubuntu|debian|el-|
|
945
|
-
when /openbsd/
|
926
|
+
when /solaris-10|ubuntu|debian|el-|huaweios/ then 'rubygems'
|
927
|
+
when /openbsd/ then 'ruby'
|
946
928
|
else
|
947
|
-
raise
|
929
|
+
raise 'install_puppet() called with default_action ' +
|
948
930
|
"'gem_install' but program `gem' is " +
|
949
931
|
"not installed on #{host.name}"
|
950
932
|
end
|
@@ -953,26 +935,20 @@ module Beaker
|
|
953
935
|
end
|
954
936
|
|
955
937
|
# Link 'gem' to /usr/bin instead of adding /opt/csw/bin to PATH.
|
956
|
-
if is_solaris10
|
957
|
-
on host, 'ln -s /opt/csw/bin/gem /usr/bin/gem'
|
958
|
-
end
|
938
|
+
on host, 'ln -s /opt/csw/bin/gem /usr/bin/gem' if is_solaris10
|
959
939
|
|
960
|
-
if host['platform'] =~ /debian|ubuntu|solaris|
|
961
|
-
gem_env = YAML.load(
|
962
|
-
gem_paths_array = gem_env['RubyGems Environment'].find {|h| h['GEM PATHS'] != nil }['GEM PATHS']
|
940
|
+
if host['platform'] =~ /debian|ubuntu|solaris|huaweios/
|
941
|
+
gem_env = YAML.load(on(host, 'gem environment').stdout)
|
942
|
+
gem_paths_array = gem_env['RubyGems Environment'].find { |h| h['GEM PATHS'] != nil }['GEM PATHS']
|
963
943
|
path_with_gem = 'export PATH=' + gem_paths_array.join(':') + ':${PATH}'
|
964
944
|
on host, "echo '#{path_with_gem}' >> ~/.bashrc"
|
965
945
|
end
|
966
946
|
|
967
947
|
gemflags = '--no-document --no-format-executable'
|
968
948
|
|
969
|
-
if opts[:facter_version]
|
970
|
-
on host, "gem install facter -v'#{opts[:facter_version]}' #{gemflags}"
|
971
|
-
end
|
949
|
+
on host, "gem install facter -v'#{opts[:facter_version]}' #{gemflags}" if opts[:facter_version]
|
972
950
|
|
973
|
-
if opts[:hiera_version]
|
974
|
-
on host, "gem install hiera -v'#{opts[:hiera_version]}' #{gemflags}"
|
975
|
-
end
|
951
|
+
on host, "gem install hiera -v'#{opts[:hiera_version]}' #{gemflags}" if opts[:hiera_version]
|
976
952
|
|
977
953
|
ver_cmd = opts[:version] ? "-v '#{opts[:version]}'" : ''
|
978
954
|
on host, "gem install puppet #{ver_cmd} #{gemflags}"
|
@@ -980,12 +956,12 @@ module Beaker
|
|
980
956
|
# Similar to the treatment of 'gem' above.
|
981
957
|
# This avoids adding /opt/csw/bin to PATH.
|
982
958
|
if is_solaris
|
983
|
-
gem_env = YAML.load(
|
959
|
+
gem_env = YAML.load(on(host, 'gem environment').stdout)
|
984
960
|
# This is the section we want - this has the dir where gem executables go.
|
985
961
|
env_sect = 'EXECUTABLE DIRECTORY'
|
986
962
|
# Get the directory where 'gem' installs executables.
|
987
963
|
# On Solaris 10 this is usually /opt/csw/bin
|
988
|
-
gem_exec_dir = gem_env['RubyGems Environment'].find {|h| h[env_sect]
|
964
|
+
gem_exec_dir = gem_env['RubyGems Environment'].find { |h| !h[env_sect].nil? }[env_sect]
|
989
965
|
|
990
966
|
on host, "ln -s #{gem_exec_dir}/hiera /usr/bin/hiera"
|
991
967
|
on host, "ln -s #{gem_exec_dir}/facter /usr/bin/facter"
|
@@ -993,15 +969,15 @@ module Beaker
|
|
993
969
|
end
|
994
970
|
|
995
971
|
# A gem install might not necessarily create these
|
996
|
-
[
|
972
|
+
%w[confdir logdir codedir].each do |key|
|
997
973
|
host.mkdir_p host.puppet[key] if host.puppet.has_key?(key)
|
998
974
|
end
|
999
975
|
|
1000
|
-
configure_type_defaults_on(
|
976
|
+
configure_type_defaults_on(host)
|
1001
977
|
end
|
1002
978
|
end
|
1003
|
-
|
1004
|
-
|
979
|
+
alias install_puppet_from_gem install_puppet_from_gem_on
|
980
|
+
alias install_puppet_agent_from_gem_on install_puppet_from_gem_on
|
1005
981
|
|
1006
982
|
# Install official puppetlabs release repository configuration on host(s).
|
1007
983
|
#
|
@@ -1010,7 +986,7 @@ module Beaker
|
|
1010
986
|
#
|
1011
987
|
# @note This method only works on redhat-like and debian-like hosts.
|
1012
988
|
#
|
1013
|
-
def install_puppetlabs_release_repo_on(
|
989
|
+
def install_puppetlabs_release_repo_on(hosts, repo = nil, opts = options)
|
1014
990
|
block_on hosts do |host|
|
1015
991
|
variant, version, arch, codename = host['platform'].to_array
|
1016
992
|
repo_name = repo || opts[:puppet_collection] || 'puppet'
|
@@ -1018,7 +994,7 @@ module Beaker
|
|
1018
994
|
|
1019
995
|
case variant
|
1020
996
|
when /^(fedora|el|redhat|centos|sles|cisco_nexus|cisco_ios_xr)$/
|
1021
|
-
variant_url_value = (
|
997
|
+
variant_url_value = (%w[redhat centos].include?(::Regexp.last_match(1)) ? 'el' : ::Regexp.last_match(1))
|
1022
998
|
if variant == 'cisco_nexus'
|
1023
999
|
variant_url_value = 'cisco-wrlinux'
|
1024
1000
|
version = '5'
|
@@ -1033,11 +1009,10 @@ module Beaker
|
|
1033
1009
|
else
|
1034
1010
|
opts[:release_yum_repo_url]
|
1035
1011
|
end
|
1036
|
-
remote =
|
1037
|
-
[url, repo_name, variant_url_value, version]
|
1012
|
+
remote = format('%s/%s-release-%s-%s.noarch.rpm', url, repo_name, variant_url_value, version)
|
1038
1013
|
else
|
1039
|
-
remote =
|
1040
|
-
|
1014
|
+
remote = format('%s/%s-release-%s-%s.noarch.rpm', opts[:release_yum_repo_url], repo_name,
|
1015
|
+
variant_url_value, version)
|
1041
1016
|
end
|
1042
1017
|
|
1043
1018
|
# sles 11 and later do not handle gpg keys well. We can't
|
@@ -1055,40 +1030,38 @@ module Beaker
|
|
1055
1030
|
|
1056
1031
|
if variant == 'cisco_nexus'
|
1057
1032
|
# cisco nexus requires using yum to install the repo
|
1058
|
-
host.install_package(
|
1033
|
+
host.install_package(remote)
|
1059
1034
|
elsif variant == 'cisco_ios_xr'
|
1060
1035
|
# cisco ios xr requires using yum to localinstall the repo
|
1061
1036
|
on host, "yum -y localinstall #{remote}"
|
1062
1037
|
else
|
1063
1038
|
opts[:package_proxy] ||= false
|
1064
|
-
host.install_package_with_rpm(
|
1065
|
-
|
1039
|
+
host.install_package_with_rpm(remote, '--replacepkgs',
|
1040
|
+
{ package_proxy: opts[:package_proxy] })
|
1066
1041
|
end
|
1067
1042
|
|
1068
|
-
when /^(debian|ubuntu|
|
1043
|
+
when /^(debian|ubuntu|huaweios)$/
|
1069
1044
|
if repo_name.match(/puppet\d*/)
|
1070
1045
|
url = if repo_name.match(/-nightly$/)
|
1071
1046
|
opts[:nightly_apt_repo_url]
|
1072
1047
|
else
|
1073
1048
|
opts[:release_apt_repo_url]
|
1074
1049
|
end
|
1075
|
-
remote =
|
1076
|
-
[url, repo_name, codename]
|
1050
|
+
remote = format('%s/%s-release-%s.deb', url, repo_name, codename)
|
1077
1051
|
else
|
1078
|
-
remote =
|
1079
|
-
[opts[:release_apt_repo_url], repo_name, codename]
|
1052
|
+
remote = format('%s/%s-release-%s.deb', opts[:release_apt_repo_url], repo_name, codename)
|
1080
1053
|
end
|
1081
1054
|
|
1082
1055
|
on host, "wget -O /tmp/puppet.deb #{remote}"
|
1083
|
-
on host,
|
1084
|
-
on host,
|
1056
|
+
on host, 'dpkg -i --force-all /tmp/puppet.deb'
|
1057
|
+
on host, 'apt-get update'
|
1085
1058
|
else
|
1086
1059
|
raise "No repository installation step for #{variant} yet..."
|
1087
1060
|
end
|
1088
|
-
configure_type_defaults_on(
|
1061
|
+
configure_type_defaults_on(host)
|
1089
1062
|
end
|
1090
1063
|
end
|
1091
|
-
|
1064
|
+
alias install_puppetlabs_release_repo install_puppetlabs_release_repo_on
|
1092
1065
|
|
1093
1066
|
# Installs the repo configs on a given host
|
1094
1067
|
#
|
@@ -1100,12 +1073,12 @@ module Beaker
|
|
1100
1073
|
#
|
1101
1074
|
# @return nil
|
1102
1075
|
def install_repo_configs(host, buildserver_url, package_name, build_version, copy_dir)
|
1103
|
-
repo_filename = host.repo_filename(
|
1104
|
-
repo_config_folder_url =
|
1105
|
-
|
1076
|
+
repo_filename = host.repo_filename(package_name, build_version)
|
1077
|
+
repo_config_folder_url = format('%s/%s/%s/repo_configs/%s/', buildserver_url, package_name, build_version,
|
1078
|
+
host.repo_type)
|
1106
1079
|
|
1107
|
-
repo_config_url = "#{
|
1108
|
-
install_repo_configs_from_url(
|
1080
|
+
repo_config_url = "#{repo_config_folder_url}/#{repo_filename}"
|
1081
|
+
install_repo_configs_from_url(host, repo_config_url, copy_dir)
|
1109
1082
|
end
|
1110
1083
|
|
1111
1084
|
# Installs the repo configs on a given host
|
@@ -1117,35 +1090,35 @@ module Beaker
|
|
1117
1090
|
# @return nil
|
1118
1091
|
def install_repo_configs_from_url(host, repo_config_url, copy_dir = nil)
|
1119
1092
|
copy_dir ||= Dir.mktmpdir
|
1120
|
-
repoconfig_filename = File.basename(
|
1121
|
-
repoconfig_folder = File.dirname(
|
1093
|
+
repoconfig_filename = File.basename(repo_config_url)
|
1094
|
+
repoconfig_folder = File.dirname(repo_config_url)
|
1122
1095
|
|
1123
1096
|
repo = fetch_http_file(
|
1124
1097
|
repoconfig_folder,
|
1125
1098
|
repoconfig_filename,
|
1126
|
-
copy_dir
|
1099
|
+
copy_dir,
|
1127
1100
|
)
|
1128
1101
|
|
1129
1102
|
if host['platform'].variant =~ /^(ubuntu|debian)$/
|
1130
1103
|
# Bypass signing checks on this repo and its packages
|
1131
1104
|
original_contents = File.read(repo)
|
1132
|
-
logger.debug
|
1105
|
+
logger.debug 'INFO original repo contents:'
|
1133
1106
|
logger.debug original_contents
|
1134
|
-
contents = original_contents.gsub(/^deb http/,
|
1135
|
-
logger.debug
|
1107
|
+
contents = original_contents.gsub(/^deb http/, 'deb [trusted=yes] http')
|
1108
|
+
logger.debug 'INFO new repo contents:'
|
1136
1109
|
logger.debug contents
|
1137
1110
|
|
1138
1111
|
File.write(repo, contents)
|
1139
1112
|
end
|
1140
1113
|
|
1141
|
-
if host[:platform] =~ /cisco_nexus/
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
scp_to(
|
1114
|
+
to_path = if host[:platform] =~ /cisco_nexus/
|
1115
|
+
"#{host.package_config_dir}/#{File.basename(repo)}"
|
1116
|
+
else
|
1117
|
+
host.package_config_dir
|
1118
|
+
end
|
1119
|
+
scp_to(host, repo, to_path)
|
1147
1120
|
|
1148
|
-
on(
|
1121
|
+
on(host, 'apt-get update') if host['platform'] =~ /ubuntu-|debian-|huaweios-/
|
1149
1122
|
nil
|
1150
1123
|
end
|
1151
1124
|
|
@@ -1171,13 +1144,14 @@ module Beaker
|
|
1171
1144
|
#
|
1172
1145
|
# @note This method only works on redhat-like and debian-like hosts.
|
1173
1146
|
#
|
1174
|
-
def install_puppetlabs_dev_repo
|
1175
|
-
|
1176
|
-
|
1147
|
+
def install_puppetlabs_dev_repo(host, package_name, build_version,
|
1148
|
+
repo_configs_dir = nil,
|
1149
|
+
opts = options)
|
1177
1150
|
variant, version, arch, codename = host['platform'].to_array
|
1178
|
-
if variant !~ /^(fedora|el|redhat|centos|debian|ubuntu|
|
1151
|
+
if variant !~ /^(fedora|el|redhat|centos|debian|ubuntu|huaweios|cisco_nexus|cisco_ios_xr|sles)$/
|
1179
1152
|
raise "No repository installation step for #{variant} yet..."
|
1180
1153
|
end
|
1154
|
+
|
1181
1155
|
repo_configs_dir ||= 'tmp/repo_configs'
|
1182
1156
|
|
1183
1157
|
platform_configs_dir = File.join(repo_configs_dir, variant)
|
@@ -1186,14 +1160,14 @@ module Beaker
|
|
1186
1160
|
# some of the uses of dev_builds_url below can't include protocol info,
|
1187
1161
|
# plus this opens up possibility of switching the behavior on provided
|
1188
1162
|
# url type
|
1189
|
-
_, protocol, hostname = opts[:dev_builds_url].partition
|
1163
|
+
_, protocol, hostname = opts[:dev_builds_url].partition %r{.*://}
|
1190
1164
|
dev_builds_url = protocol + hostname
|
1191
1165
|
dev_builds_url = opts[:dev_builds_url] if variant =~ /^(fedora|el|redhat|centos)$/
|
1192
1166
|
|
1193
|
-
install_repo_configs(
|
1194
|
-
|
1167
|
+
install_repo_configs(host, dev_builds_url, package_name,
|
1168
|
+
build_version, platform_configs_dir)
|
1195
1169
|
|
1196
|
-
configure_type_defaults_on(
|
1170
|
+
configure_type_defaults_on(host)
|
1197
1171
|
end
|
1198
1172
|
|
1199
1173
|
# Installs packages from the local development repository on the given host
|
@@ -1206,8 +1180,8 @@ module Beaker
|
|
1206
1180
|
# @note This method only works on redhat-like and debian-like hosts.
|
1207
1181
|
# @note This method is paired to be run directly after {#install_puppetlabs_dev_repo}
|
1208
1182
|
#
|
1209
|
-
def install_packages_from_local_dev_repo(
|
1210
|
-
if host['platform'] =~ /debian|ubuntu|
|
1183
|
+
def install_packages_from_local_dev_repo(host, package_name)
|
1184
|
+
if host['platform'] =~ /debian|ubuntu|huaweios/
|
1211
1185
|
find_filename = '*.deb'
|
1212
1186
|
find_command = 'dpkg -i'
|
1213
1187
|
elsif host['platform'] =~ /fedora|el|redhat|centos/
|
@@ -1218,7 +1192,7 @@ module Beaker
|
|
1218
1192
|
end
|
1219
1193
|
find_command = "find /root/#{package_name} -type f -name '#{find_filename}' -exec #{find_command} {} \\;"
|
1220
1194
|
on host, find_command
|
1221
|
-
configure_type_defaults_on(
|
1195
|
+
configure_type_defaults_on(host)
|
1222
1196
|
end
|
1223
1197
|
|
1224
1198
|
# Install development repo of the puppet-agent on the given host(s). Downloaded from
|
@@ -1256,40 +1230,39 @@ module Beaker
|
|
1256
1230
|
# install_puppet_agent_dev_repo_on(host, { :puppet_agent_sha => 'd3377feaeac173aada3a2c2cedd141eb610960a7', :puppet_agent_version => '1.1.1.225.gd3377fe' })
|
1257
1231
|
#
|
1258
1232
|
# @return nil
|
1259
|
-
def install_puppet_agent_dev_repo_on(
|
1260
|
-
|
1261
|
-
global_opts[:puppet_agent_version]
|
1262
|
-
|
1263
|
-
raise "must provide :puppet_agent_version (puppet-agent version) for install_puppet_agent_dev_repo_on"
|
1233
|
+
def install_puppet_agent_dev_repo_on(hosts, global_opts)
|
1234
|
+
global_opts[:puppet_agent_version] ||= global_opts[:version] # backward compatability
|
1235
|
+
unless global_opts[:puppet_agent_version]
|
1236
|
+
raise 'must provide :puppet_agent_version (puppet-agent version) for install_puppet_agent_dev_repo_on'
|
1264
1237
|
end
|
1265
1238
|
|
1266
1239
|
block_on hosts do |host|
|
1267
1240
|
opts = global_opts.dup
|
1268
1241
|
|
1269
|
-
# TODO consolidate these values as they serve no purpose from beaker's side
|
1242
|
+
# TODO: consolidate these values as they serve no purpose from beaker's side
|
1270
1243
|
# you could provide any values you could to one to the other
|
1271
1244
|
puppet_agent_version = opts[:puppet_agent_sha] || opts[:puppet_agent_version]
|
1272
1245
|
|
1273
1246
|
opts = sanitize_opts(opts)
|
1274
|
-
opts[:download_url] = "#{opts[:dev_builds_url]}/puppet-agent/#{
|
1247
|
+
opts[:download_url] = "#{opts[:dev_builds_url]}/puppet-agent/#{puppet_agent_version}/repos/"
|
1275
1248
|
opts[:copy_base_local] ||= File.join('tmp', 'repo_configs')
|
1276
1249
|
opts[:puppet_collection] ||= 'PC1'
|
1277
1250
|
|
1278
1251
|
release_path = opts[:download_url]
|
1279
1252
|
|
1280
1253
|
variant, version, arch, codename = host['platform'].to_array
|
1281
|
-
add_role(host, 'aio') #we are installing agent, so we want aio role
|
1254
|
+
add_role(host, 'aio') # we are installing agent, so we want aio role
|
1282
1255
|
copy_dir_local = File.join(opts[:copy_base_local], variant)
|
1283
1256
|
onhost_copy_base = opts[:copy_dir_external] || host.external_copy_base
|
1284
1257
|
|
1285
1258
|
case variant
|
1286
|
-
when /^(fedora|el|redhat|centos|debian|ubuntu|
|
1287
|
-
if arch== 's390x' || host['hypervisor'] == 'ec2'
|
1259
|
+
when /^(fedora|el|redhat|centos|debian|ubuntu|huaweios|cisco_nexus|cisco_ios_xr)$/
|
1260
|
+
if arch == 's390x' || host['hypervisor'] == 'ec2'
|
1288
1261
|
logger.trace("#install_puppet_agent_dev_repo_on: unsupported host #{host} for repo detected. using dev package")
|
1289
1262
|
else
|
1290
|
-
install_puppetlabs_dev_repo(
|
1263
|
+
install_puppetlabs_dev_repo(host, 'puppet-agent', puppet_agent_version, nil, opts)
|
1291
1264
|
host.install_package('puppet-agent')
|
1292
|
-
logger.trace(
|
1265
|
+
logger.trace('#install_puppet_agent_dev_repo_on: install_puppetlabs_dev_repo finished')
|
1293
1266
|
next
|
1294
1267
|
end
|
1295
1268
|
when /^(eos|osx|windows|solaris|sles|aix)$/
|
@@ -1301,44 +1274,43 @@ module Beaker
|
|
1301
1274
|
end
|
1302
1275
|
|
1303
1276
|
release_path_end, release_file = host.puppet_agent_dev_package_info(
|
1304
|
-
opts[:puppet_collection], opts[:puppet_agent_version], opts
|
1277
|
+
opts[:puppet_collection], opts[:puppet_agent_version], opts
|
1278
|
+
)
|
1305
1279
|
release_path << release_path_end
|
1306
|
-
logger.trace(
|
1280
|
+
logger.trace('#install_puppet_agent_dev_repo_on: dev_package_info, continuing...')
|
1307
1281
|
|
1308
1282
|
if variant =~ /eos/
|
1309
|
-
host.get_remote_file(
|
1283
|
+
host.get_remote_file("#{release_path}/#{release_file}")
|
1310
1284
|
else
|
1311
1285
|
onhost_copied_file = File.join(onhost_copy_base, release_file)
|
1312
|
-
fetch_http_file(
|
1286
|
+
fetch_http_file(release_path, release_file, copy_dir_local)
|
1313
1287
|
scp_to host, File.join(copy_dir_local, release_file), onhost_copy_base
|
1314
1288
|
end
|
1315
1289
|
|
1316
1290
|
case variant
|
1317
1291
|
when /^eos/
|
1318
|
-
host.install_from_file(
|
1292
|
+
host.install_from_file(release_file)
|
1319
1293
|
when /^(sles|aix|fedora|el|redhat|centos)$/
|
1320
1294
|
# NOTE: AIX does not support repo management. This block assumes
|
1321
1295
|
# that the desired rpm has been mirrored to the 'repos' location.
|
1322
1296
|
# NOTE: the AIX 7.1 package will only install on 7.2 with
|
1323
1297
|
# --ignoreos. This is a bug in package building on AIX 7.1's RPM
|
1324
|
-
if variant ==
|
1325
|
-
aix_72_ignoreos_hack = "--ignoreos"
|
1326
|
-
end
|
1298
|
+
aix_72_ignoreos_hack = '--ignoreos' if variant == 'aix' && version == '7.2'
|
1327
1299
|
on host, "rpm -ivh #{aix_72_ignoreos_hack} #{onhost_copied_file}"
|
1328
1300
|
when /^windows$/
|
1329
1301
|
result = on host, "echo #{onhost_copied_file}"
|
1330
1302
|
onhost_copied_file = result.raw_output.chomp
|
1331
|
-
msi_opts = { :
|
1303
|
+
msi_opts = { debug: host[:pe_debug] || opts[:pe_debug] }
|
1332
1304
|
install_msi_on(host, onhost_copied_file, {}, msi_opts)
|
1333
1305
|
when /^osx$/
|
1334
1306
|
host.install_package("puppet-agent-#{opts[:puppet_agent_version]}*")
|
1335
1307
|
when /^solaris$/
|
1336
|
-
host.solaris_install_local_package(
|
1308
|
+
host.solaris_install_local_package(release_file, onhost_copy_base)
|
1337
1309
|
end
|
1338
|
-
configure_type_defaults_on(
|
1310
|
+
configure_type_defaults_on(host)
|
1339
1311
|
end
|
1340
1312
|
end
|
1341
|
-
|
1313
|
+
alias install_puppetagent_dev_repo install_puppet_agent_dev_repo_on
|
1342
1314
|
|
1343
1315
|
# Install shared repo of the puppet-agent on the given host(s). Downloaded from
|
1344
1316
|
# location of the form PE_PROMOTED_BUILDS_URL/PE_VER/puppet-agent/AGENT_VERSION/repo
|
@@ -1364,17 +1336,18 @@ module Beaker
|
|
1364
1336
|
# install_puppet_agent_pe_promoted_repo_on(host, { :puppet_agent_version => '1.1.0.227', :pe_ver => '4.0.0-rc1'})
|
1365
1337
|
#
|
1366
1338
|
# @return nil
|
1367
|
-
def install_puppet_agent_pe_promoted_repo_on(
|
1339
|
+
def install_puppet_agent_pe_promoted_repo_on(hosts, opts)
|
1368
1340
|
opts[:puppet_agent_version] ||= 'latest'
|
1369
1341
|
|
1370
1342
|
block_on hosts do |host|
|
1371
1343
|
pe_ver = host[:pe_ver] || opts[:pe_ver] || '4.0.0-rc1'
|
1372
1344
|
opts = sanitize_opts(opts)
|
1373
|
-
opts[:download_url] =
|
1345
|
+
opts[:download_url] =
|
1346
|
+
"#{opts[:pe_promoted_builds_url]}/puppet-agent/#{pe_ver}/#{opts[:puppet_agent_version]}/repos"
|
1374
1347
|
opts[:copy_base_local] ||= File.join('tmp', 'repo_configs')
|
1375
1348
|
opts[:copy_dir_external] ||= host.external_copy_base
|
1376
1349
|
opts[:puppet_collection] ||= puppet_collection_for(:puppet_agent, opts[:puppet_agent_version])
|
1377
|
-
add_role(host, 'aio') #we are installing agent, so we want aio role
|
1350
|
+
add_role(host, 'aio') # we are installing agent, so we want aio role
|
1378
1351
|
release_path = opts[:download_url]
|
1379
1352
|
variant, version, arch, codename = host['platform'].to_array
|
1380
1353
|
copy_dir_local = File.join(opts[:copy_base_local], variant)
|
@@ -1388,13 +1361,13 @@ module Beaker
|
|
1388
1361
|
|
1389
1362
|
onhost_copied_download = File.join(onhost_copy_base, download_file)
|
1390
1363
|
onhost_copied_file = File.join(onhost_copy_base, release_file)
|
1391
|
-
fetch_http_file(
|
1364
|
+
fetch_http_file(release_path, download_file, copy_dir_local)
|
1392
1365
|
scp_to host, File.join(copy_dir_local, download_file), onhost_copy_base
|
1393
1366
|
|
1394
1367
|
if variant == 'windows'
|
1395
1368
|
result = on host, "echo #{onhost_copied_file}"
|
1396
1369
|
onhost_copied_file = result.raw_output.chomp
|
1397
|
-
opts = { :
|
1370
|
+
opts = { debug: host[:pe_debug] || opts[:pe_debug] }
|
1398
1371
|
# couldn't pull this out, because it's relying on
|
1399
1372
|
# {Beaker::DSL::InstallUtils::WindowsUtils} methods,
|
1400
1373
|
# which I didn't want to attack right now. TODO
|
@@ -1405,7 +1378,7 @@ module Beaker
|
|
1405
1378
|
onhost_copied_file, download_file, opts
|
1406
1379
|
)
|
1407
1380
|
end
|
1408
|
-
configure_type_defaults_on(
|
1381
|
+
configure_type_defaults_on(host)
|
1409
1382
|
end
|
1410
1383
|
end
|
1411
1384
|
|
@@ -1472,9 +1445,7 @@ module Beaker
|
|
1472
1445
|
host[:type] = :aio
|
1473
1446
|
|
1474
1447
|
if opts[:version] == 'latest'
|
1475
|
-
if opts[:nightlies]
|
1476
|
-
release_stream += '-nightly' unless release_stream.end_with? "-nightly"
|
1477
|
-
end
|
1448
|
+
release_stream += '-nightly' if opts[:nightlies] && !(release_stream.end_with? '-nightly')
|
1478
1449
|
|
1479
1450
|
# Since we have modified the collection, we don't want to pass `latest`
|
1480
1451
|
# in to `install_package` as the version. That'll fail. Instead, if
|
@@ -1485,7 +1456,7 @@ module Beaker
|
|
1485
1456
|
|
1486
1457
|
# We have to do some silly version munging if we're on a deb-based platform
|
1487
1458
|
case host['platform']
|
1488
|
-
when /debian|ubuntu|
|
1459
|
+
when /debian|ubuntu|huaweios/
|
1489
1460
|
opts[:version] = "#{opts[:version]}-1#{host['platform'].codename}" if opts[:version]
|
1490
1461
|
end
|
1491
1462
|
|
@@ -1502,49 +1473,52 @@ module Beaker
|
|
1502
1473
|
#
|
1503
1474
|
# @return nil
|
1504
1475
|
# @api public
|
1505
|
-
def remove_puppet_on(
|
1476
|
+
def remove_puppet_on(hosts)
|
1506
1477
|
block_on hosts do |host|
|
1507
1478
|
cmdline_args = ''
|
1508
1479
|
# query packages
|
1509
1480
|
case host[:platform]
|
1510
|
-
when /
|
1511
|
-
pkgs = on(host, "dpkg-query -l | awk '{print $2}' | grep -E '(^pe-|puppet)'",
|
1481
|
+
when /huaweios|ubuntu/
|
1482
|
+
pkgs = on(host, "dpkg-query -l | awk '{print $2}' | grep -E '(^pe-|puppet)'",
|
1483
|
+
acceptable_exit_codes: [0, 1]).stdout.chomp.split(/\n+/)
|
1512
1484
|
when /aix|sles|el|redhat|centos|oracle|scientific/
|
1513
|
-
pkgs = on(host, "rpm -qa | grep -E '(^pe-|puppet)'",
|
1485
|
+
pkgs = on(host, "rpm -qa | grep -E '(^pe-|puppet)'",
|
1486
|
+
acceptable_exit_codes: [0, 1]).stdout.chomp.split(/\n+/)
|
1514
1487
|
when /solaris-10/
|
1515
1488
|
cmdline_args = '-a noask'
|
1516
|
-
pkgs = on(host, "pkginfo | egrep '(^pe-|puppet)' | cut -f2 -d ' '",
|
1489
|
+
pkgs = on(host, "pkginfo | egrep '(^pe-|puppet)' | cut -f2 -d ' '",
|
1490
|
+
acceptable_exit_codes: [0, 1]).stdout.chomp.split(/\n+/)
|
1517
1491
|
when /solaris-11/
|
1518
|
-
pkgs = on(host, "pkg list | egrep '(^pe-|puppet)' | awk '{print $1}'",
|
1492
|
+
pkgs = on(host, "pkg list | egrep '(^pe-|puppet)' | awk '{print $1}'",
|
1493
|
+
acceptable_exit_codes: [0, 1]).stdout.chomp.split(/\n+/)
|
1519
1494
|
else
|
1520
|
-
raise
|
1495
|
+
raise 'remove_puppet_on() called for unsupported ' +
|
1521
1496
|
"platform '#{host['platform']}' on '#{host.name}'"
|
1522
1497
|
end
|
1523
1498
|
|
1524
1499
|
# uninstall packages
|
1525
1500
|
host.uninstall_package(pkgs.join(' '), cmdline_args) if pkgs.length > 0
|
1526
1501
|
|
1527
|
-
if host[:platform] =~ /solaris-11/
|
1502
|
+
if host[:platform] =~ /solaris-11/
|
1528
1503
|
# FIXME: This leaves things in a state where Puppet Enterprise (3.x) cannot be cleanly installed
|
1529
1504
|
# but is required to put things in a state that puppet-agent can be installed
|
1530
1505
|
# extra magic for expunging left over publisher
|
1531
1506
|
publishers = ['puppetlabs.com', 'com.puppetlabs']
|
1532
1507
|
publishers.each do |publisher|
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1508
|
+
# First, try to remove the publisher altogether
|
1509
|
+
next unless on(host, "pkg publisher #{publisher}",
|
1510
|
+
acceptable_exit_codes: [0, 1]).exit_code == 0 && (on(host, "pkg unset-publisher #{publisher}",
|
1511
|
+
acceptable_exit_codes: [0, 1]).exit_code == 1)
|
1512
|
+
|
1513
|
+
# If that doesn't work, we're in a non-global zone and the
|
1514
|
+
# publisher is from a global zone. As such, just remove any
|
1515
|
+
# references to the non-global zone uri.
|
1516
|
+
on(host, "pkg set-publisher -G '*' #{publisher}", acceptable_exit_codes: [0, 1])
|
1542
1517
|
end
|
1543
1518
|
end
|
1544
1519
|
|
1545
1520
|
# delete any residual files
|
1546
1521
|
on(host, 'find / -name "*puppet*" -print | xargs rm -rf')
|
1547
|
-
|
1548
1522
|
end
|
1549
1523
|
end
|
1550
1524
|
|
@@ -1562,40 +1536,39 @@ module Beaker
|
|
1562
1536
|
# @return true
|
1563
1537
|
def install_packages_on(hosts, package_hash, options = {})
|
1564
1538
|
platform_patterns = {
|
1565
|
-
:
|
1566
|
-
:
|
1567
|
-
:
|
1568
|
-
:
|
1569
|
-
:
|
1570
|
-
:
|
1571
|
-
:
|
1572
|
-
:
|
1539
|
+
redhat: /fedora|el-|centos/,
|
1540
|
+
debian: /debian|ubuntu/,
|
1541
|
+
debian_ruby18: /debian|ubuntu-lucid|ubuntu-precise/,
|
1542
|
+
solaris_10: /solaris-10/,
|
1543
|
+
solaris_11: /solaris-11/,
|
1544
|
+
windows: /windows/,
|
1545
|
+
eos: /^eos-/,
|
1546
|
+
sles: /sles/,
|
1573
1547
|
}.freeze
|
1574
1548
|
|
1575
1549
|
check_if_exists = options[:check_if_exists]
|
1576
1550
|
Array(hosts).each do |host|
|
1577
|
-
package_hash.each do |platform_key,package_list|
|
1578
|
-
|
1579
|
-
if pattern.match(host['platform'])
|
1580
|
-
package_list.each do |cmd_pkg|
|
1581
|
-
if cmd_pkg.kind_of?(Array)
|
1582
|
-
command, package = cmd_pkg
|
1583
|
-
else
|
1584
|
-
command = package = cmd_pkg
|
1585
|
-
end
|
1586
|
-
if !check_if_exists || !host.check_for_package(command)
|
1587
|
-
host.logger.notify("Installing #{package}")
|
1588
|
-
additional_switches = '--allow-unauthenticated' if platform_key == :debian
|
1589
|
-
host.install_package(package, additional_switches)
|
1590
|
-
end
|
1591
|
-
end
|
1592
|
-
end
|
1593
|
-
else
|
1551
|
+
package_hash.each do |platform_key, package_list|
|
1552
|
+
unless pattern = platform_patterns[platform_key]
|
1594
1553
|
raise("Unknown platform '#{platform_key}' in package_hash")
|
1595
1554
|
end
|
1555
|
+
next unless pattern.match(host['platform'])
|
1556
|
+
|
1557
|
+
package_list.each do |cmd_pkg|
|
1558
|
+
if cmd_pkg.is_a?(Array)
|
1559
|
+
command, package = cmd_pkg
|
1560
|
+
else
|
1561
|
+
command = package = cmd_pkg
|
1562
|
+
end
|
1563
|
+
next unless !check_if_exists || !host.check_for_package(command)
|
1564
|
+
|
1565
|
+
host.logger.notify("Installing #{package}")
|
1566
|
+
additional_switches = '--allow-unauthenticated' if platform_key == :debian
|
1567
|
+
host.install_package(package, additional_switches)
|
1568
|
+
end
|
1596
1569
|
end
|
1597
1570
|
end
|
1598
|
-
|
1571
|
+
true
|
1599
1572
|
end
|
1600
1573
|
|
1601
1574
|
def ruby_command(host)
|
@@ -1603,7 +1576,7 @@ module Beaker
|
|
1603
1576
|
end
|
1604
1577
|
|
1605
1578
|
def get_command(command_name, host, type = 'aio')
|
1606
|
-
if [
|
1579
|
+
if %w[aio git].include?(type)
|
1607
1580
|
if host['platform'] =~ /windows/
|
1608
1581
|
"env PATH=\"#{host['privatebindir']}:${PATH}\" cmd /c #{command_name}"
|
1609
1582
|
else
|
@@ -1625,18 +1598,18 @@ module Beaker
|
|
1625
1598
|
# Configures gem sources on hosts to use a mirror, if specified
|
1626
1599
|
# This is a duplicate of the Gemfile logic.
|
1627
1600
|
def configure_gem_mirror(hosts)
|
1628
|
-
gem_source = ENV
|
1601
|
+
gem_source = ENV.fetch('GEM_SOURCE', nil)
|
1629
1602
|
|
1630
1603
|
# Newer versions of rubygems always default the source to https://rubygems.org
|
1631
1604
|
# and versions >= 3.1 will try to prompt (and fail) if you add a source that is
|
1632
1605
|
# too similar to rubygems.org to prevent typo squatting:
|
1633
1606
|
# https://github.com/rubygems/rubygems/commit/aa967b85dd96bbfb350f104125f23d617e82a00a
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1607
|
+
return unless gem_source && gem_source !~ /rubygems\.org/
|
1608
|
+
|
1609
|
+
Array(hosts).each do |host|
|
1610
|
+
gem = gem_command(host)
|
1611
|
+
on host, "#{gem} source --clear-all"
|
1612
|
+
on(host, "#{gem} source --add #{gem_source}")
|
1640
1613
|
end
|
1641
1614
|
end
|
1642
1615
|
end
|