beaker-puppet 1.29.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +3 -3
- data/.github/workflows/test.yml +28 -7
- data/.github_changelog_generator +3 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +887 -0
- data/CHANGELOG.md +50 -0
- data/CODEOWNERS +1 -0
- data/Gemfile +5 -20
- data/README.md +4 -13
- 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 +17 -24
- 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 +145 -229
- 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 +269 -480
- 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 +53 -80
- 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/release-prep.sh +11 -0
- data/setup/aio/010_Install_Puppet_Agent.rb +22 -9
- 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 +9 -18
- data/setup/common/045_EnsureMasterStarted.rb +2 -2
- data/setup/gem/010_GemInstall.rb +6 -5
- 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 +463 -724
- 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 +471 -863
- 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 +89 -97
- 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 +188 -188
- metadata +38 -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
@@ -5,21 +5,20 @@ module Beaker
|
|
5
5
|
# This module contains methods useful for both foss and pe installs
|
6
6
|
#
|
7
7
|
module PuppetUtils
|
8
|
-
|
9
|
-
#
|
10
|
-
|
11
|
-
#@return [String] The normalized type
|
8
|
+
# Given a type return an understood host type
|
9
|
+
# @param [String] type The host type to be normalized
|
10
|
+
# @return [String] The normalized type
|
12
11
|
#
|
13
|
-
|
12
|
+
# @example
|
14
13
|
# normalize_type('pe-aio')
|
15
14
|
# 'pe'
|
16
|
-
|
15
|
+
# @example
|
17
16
|
# normalize_type('git')
|
18
17
|
# 'foss'
|
19
|
-
|
18
|
+
# @example
|
20
19
|
# normalize_type('foss-internal')
|
21
20
|
# 'foss'
|
22
|
-
def normalize_type
|
21
|
+
def normalize_type(type)
|
23
22
|
case type
|
24
23
|
when /(\A|-)foss(\Z|-)/
|
25
24
|
'foss'
|
@@ -27,66 +26,45 @@ module Beaker
|
|
27
26
|
'pe'
|
28
27
|
when /(\A|-)aio(\Z|-)/
|
29
28
|
'aio'
|
30
|
-
else
|
31
|
-
nil
|
32
29
|
end
|
33
30
|
end
|
34
31
|
|
35
|
-
#Given a host construct a PATH that includes puppetbindir, facterbindir and hierabindir
|
32
|
+
# Given a host construct a PATH that includes puppetbindir, facterbindir and hierabindir
|
36
33
|
# @param [Host] host A single host to construct pathing for
|
37
34
|
def construct_puppet_path(host)
|
38
|
-
path =
|
39
|
-
#get the PATH defaults
|
35
|
+
path = %w[puppetbindir facterbindir hierabindir privatebindir].compact.reject(&:empty?)
|
36
|
+
# get the PATH defaults
|
40
37
|
path.map! { |val| host[val] }
|
41
38
|
path = path.compact.reject(&:empty?)
|
42
|
-
#run the paths through echo to see if they have any subcommands that need processing
|
39
|
+
# run the paths through echo to see if they have any subcommands that need processing
|
43
40
|
path.map! { |val| echo_on(host, val) }
|
44
41
|
|
45
42
|
separator = host['pathseparator']
|
46
|
-
|
47
|
-
separator = ':'
|
48
|
-
end
|
43
|
+
separator = ':' unless host.is_powershell?
|
49
44
|
path.join(separator)
|
50
45
|
end
|
51
46
|
|
52
|
-
#Append puppetbindir, facterbindir and hierabindir to the PATH for each host
|
47
|
+
# Append puppetbindir, facterbindir and hierabindir to the PATH for each host
|
53
48
|
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
54
49
|
# or a role (String or Symbol) that identifies one or more hosts.
|
55
50
|
def add_puppet_paths_on(hosts)
|
56
|
-
block_on hosts do |
|
51
|
+
block_on hosts do |host|
|
57
52
|
puppet_path = construct_puppet_path(host)
|
58
53
|
host.add_env_var('PATH', puppet_path)
|
59
54
|
end
|
60
55
|
end
|
61
56
|
|
62
|
-
#Remove puppetbindir, facterbindir and hierabindir to the PATH for each host
|
57
|
+
# Remove puppetbindir, facterbindir and hierabindir to the PATH for each host
|
63
58
|
#
|
64
59
|
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
65
60
|
# or a role (String or Symbol) that identifies one or more hosts.
|
66
61
|
def remove_puppet_paths_on(hosts)
|
67
|
-
block_on hosts do |
|
62
|
+
block_on hosts do |host|
|
68
63
|
puppet_path = construct_puppet_path(host)
|
69
64
|
host.delete_env_var('PATH', puppet_path)
|
70
65
|
end
|
71
66
|
end
|
72
67
|
|
73
|
-
# Given an agent_version, return the puppet collection associated with that agent version
|
74
|
-
#
|
75
|
-
# @param [String] agent_version version string or 'latest'
|
76
|
-
# @deprecated This method returns 'PC1' as the latest puppet collection;
|
77
|
-
# this is incorrect. Use {#puppet_collection_for} instead.
|
78
|
-
def get_puppet_collection(agent_version = 'latest')
|
79
|
-
collection = "PC1"
|
80
|
-
if agent_version != 'latest'
|
81
|
-
if ! version_is_less( agent_version, "5.5.4") and version_is_less(agent_version, "5.99")
|
82
|
-
collection = "puppet5"
|
83
|
-
elsif ! version_is_less( agent_version, "5.99")
|
84
|
-
collection = "puppet6"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
collection
|
88
|
-
end
|
89
|
-
|
90
68
|
# Determine the puppet collection that matches a given package version. The package
|
91
69
|
# must be one of
|
92
70
|
# * :puppet_agent (you can get this version from the `aio_agent_version_fact`)
|
@@ -98,15 +76,13 @@ module Beaker
|
|
98
76
|
# @param version [String] a version number or the string 'latest'
|
99
77
|
# @returns [String|nil] the name of the corresponding puppet collection, if any
|
100
78
|
def puppet_collection_for(package, version)
|
101
|
-
valid_packages = [
|
102
|
-
|
103
|
-
|
104
|
-
|
79
|
+
valid_packages = %i[
|
80
|
+
puppet_agent
|
81
|
+
puppet
|
82
|
+
puppetserver
|
105
83
|
]
|
106
84
|
|
107
|
-
unless valid_packages.include?(package)
|
108
|
-
raise "package must be one of #{valid_packages.join(', ')}"
|
109
|
-
end
|
85
|
+
raise "package must be one of #{valid_packages.join(', ')}" unless valid_packages.include?(package)
|
110
86
|
|
111
87
|
case package
|
112
88
|
when :puppet_agent, :puppet, :puppetserver
|
@@ -119,7 +95,7 @@ module Beaker
|
|
119
95
|
pc1_x = {
|
120
96
|
puppet: 4,
|
121
97
|
puppet_agent: 1,
|
122
|
-
puppetserver: 2
|
98
|
+
puppetserver: 2,
|
123
99
|
}
|
124
100
|
|
125
101
|
return 'pc1' if x == pc1_x[package]
|
@@ -136,9 +112,8 @@ module Beaker
|
|
136
112
|
# @returns [String|nil] The version of puppet-agent, or nil if puppet-agent is not installed
|
137
113
|
def puppet_agent_version_on(host)
|
138
114
|
result = on(host, facter('aio_agent_version'), accept_all_exit_codes: true)
|
139
|
-
if result.exit_code.zero?
|
140
|
-
|
141
|
-
end
|
115
|
+
return result.stdout.strip if result.exit_code.zero?
|
116
|
+
|
142
117
|
nil
|
143
118
|
end
|
144
119
|
|
@@ -149,36 +124,36 @@ module Beaker
|
|
149
124
|
def puppetserver_version_on(host)
|
150
125
|
result = on(host, 'puppetserver --version', accept_all_exit_codes: true)
|
151
126
|
if result.exit_code.zero?
|
152
|
-
matched = result.stdout.strip.scan(
|
127
|
+
matched = result.stdout.strip.scan(/\d+\.\d+\.\d+/)
|
153
128
|
return matched.first
|
154
129
|
end
|
155
130
|
nil
|
156
131
|
end
|
157
132
|
|
158
|
-
#Configure the provided hosts to be of the provided type (one of foss, aio, pe), if the host
|
159
|
-
#is already associated with a type then remove the previous settings for that type
|
133
|
+
# Configure the provided hosts to be of the provided type (one of foss, aio, pe), if the host
|
134
|
+
# is already associated with a type then remove the previous settings for that type
|
160
135
|
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
161
136
|
# or a role (String or Symbol) that identifies one or more hosts.
|
162
137
|
# @param [String] type One of 'aio', 'pe' or 'foss'
|
163
|
-
def configure_defaults_on(
|
138
|
+
def configure_defaults_on(hosts, type)
|
164
139
|
block_on hosts do |host|
|
165
|
-
|
166
140
|
# check to see if the host already has a type associated with it
|
167
141
|
remove_defaults_on(host)
|
168
142
|
|
169
143
|
add_method = "add_#{type}_defaults_on"
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
144
|
+
raise "cannot add defaults of type #{type} for host #{host.name} (#{add_method} not present)" unless respond_to?(
|
145
|
+
add_method, host
|
146
|
+
)
|
147
|
+
|
148
|
+
send(add_method, host)
|
149
|
+
|
175
150
|
# add pathing env
|
176
151
|
add_puppet_paths_on(host)
|
177
152
|
end
|
178
153
|
end
|
179
154
|
|
180
155
|
# Configure the provided hosts to be of their host[:type], it host[type] == nil do nothing
|
181
|
-
def configure_type_defaults_on(
|
156
|
+
def configure_type_defaults_on(hosts)
|
182
157
|
block_on hosts do |host|
|
183
158
|
has_defaults = false
|
184
159
|
if host[:type]
|
@@ -189,11 +164,12 @@ module Beaker
|
|
189
164
|
host_type = normalize_type(host_type)
|
190
165
|
if host_type and host_type !~ /aio/
|
191
166
|
add_method = "add_#{host_type}_defaults_on"
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
167
|
+
raise "cannot add defaults of type #{host_type} for host #{host.name} (#{add_method} not present)" unless respond_to?(
|
168
|
+
add_method, host
|
169
|
+
)
|
170
|
+
|
171
|
+
send(add_method, host)
|
172
|
+
|
197
173
|
has_defaults = true
|
198
174
|
end
|
199
175
|
end
|
@@ -202,18 +178,16 @@ module Beaker
|
|
202
178
|
has_defaults = true
|
203
179
|
end
|
204
180
|
# add pathing env
|
205
|
-
if has_defaults
|
206
|
-
add_puppet_paths_on(host)
|
207
|
-
end
|
181
|
+
add_puppet_paths_on(host) if has_defaults
|
208
182
|
end
|
209
183
|
end
|
210
|
-
|
211
|
-
|
184
|
+
alias configure_foss_defaults_on configure_type_defaults_on
|
185
|
+
alias configure_pe_defaults_on configure_type_defaults_on
|
212
186
|
|
213
|
-
#If the host is associated with a type remove all defaults and environment associated with that type.
|
187
|
+
# If the host is associated with a type remove all defaults and environment associated with that type.
|
214
188
|
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
215
189
|
# or a role (String or Symbol) that identifies one or more hosts.
|
216
|
-
def remove_defaults_on(
|
190
|
+
def remove_defaults_on(hosts)
|
217
191
|
block_on hosts do |host|
|
218
192
|
if host['type']
|
219
193
|
# clean up the naming conventions here (some teams use foss-package, git-whatever, we need
|
@@ -222,14 +196,13 @@ module Beaker
|
|
222
196
|
host_type = normalize_type(host['type'])
|
223
197
|
remove_puppet_paths_on(hosts)
|
224
198
|
remove_method = "remove_#{host_type}_defaults_on"
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
end
|
199
|
+
raise "cannot remove defaults of type #{host_type} associated with host #{host.name} (#{remove_method} not present)" unless respond_to?(
|
200
|
+
remove_method, host
|
201
|
+
)
|
202
|
+
|
203
|
+
send(remove_method, host)
|
204
|
+
|
205
|
+
remove_aio_defaults_on(host) if aio_version?(host)
|
233
206
|
end
|
234
207
|
end
|
235
208
|
end
|
@@ -13,7 +13,7 @@ module Beaker
|
|
13
13
|
def get_system_temp_path(host)
|
14
14
|
host.system_temp_path
|
15
15
|
end
|
16
|
-
|
16
|
+
alias get_temp_path get_system_temp_path
|
17
17
|
|
18
18
|
# Generates commands to be inserted into a Windows batch file to launch an MSI install
|
19
19
|
# @param [String] msi_path The path of the MSI - can be a local Windows style file path like
|
@@ -25,15 +25,15 @@ module Beaker
|
|
25
25
|
# @api private
|
26
26
|
def msi_install_script(msi_path, msi_opts, log_path)
|
27
27
|
# msiexec requires backslashes in file paths launched under cmd.exe start /w
|
28
|
-
url_pattern =
|
29
|
-
msi_path = msi_path.gsub(
|
28
|
+
url_pattern = %r{^(https?|file)://}
|
29
|
+
msi_path = msi_path.gsub(%r{/}, '\\') if msi_path !~ url_pattern
|
30
30
|
|
31
|
-
msi_params = msi_opts.map{|k, v| "#{k}=#{v}"}.join(' ')
|
31
|
+
msi_params = msi_opts.map { |k, v| "#{k}=#{v}" }.join(' ')
|
32
32
|
|
33
33
|
# msiexec requires quotes around paths with backslashes - c:\ or file://c:\
|
34
34
|
# not strictly needed for http:// but it simplifies this code
|
35
35
|
batch_contents = <<~BATCH
|
36
|
-
start /w msiexec.exe /i
|
36
|
+
start /w msiexec.exe /i "#{msi_path}" /qn /L*V #{log_path} #{msi_params}
|
37
37
|
exit /B %errorlevel%
|
38
38
|
BATCH
|
39
39
|
end
|
@@ -67,7 +67,7 @@ module Beaker
|
|
67
67
|
host.do_scp_to(tmp_file.path, batch_path, {})
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
[batch_path, log_path]
|
71
71
|
end
|
72
72
|
|
73
73
|
# Given hosts construct a PATH that includes puppetbindir, facterbindir and hierabindir
|
@@ -112,34 +112,31 @@ module Beaker
|
|
112
112
|
#
|
113
113
|
# @api private
|
114
114
|
def install_msi_on(hosts, msi_path, msi_opts = {}, opts = {})
|
115
|
-
block_on hosts do |
|
115
|
+
block_on hosts do |host|
|
116
116
|
msi_opts['PUPPET_AGENT_STARTUP_MODE'] ||= 'Manual'
|
117
117
|
batch_path, log_file = create_install_msi_batch_on(host, msi_path, msi_opts)
|
118
118
|
# Powershell command looses an escaped slash resulting in cygwin relative path
|
119
119
|
# See https://github.com/puppetlabs/beaker/pull/1626#issuecomment-621341555
|
120
|
-
log_file_escaped = log_file.gsub('\\','\\\\\\')
|
120
|
+
log_file_escaped = log_file.gsub('\\', '\\\\\\')
|
121
121
|
# begin / rescue here so that we can reuse existing error msg propagation
|
122
122
|
begin
|
123
123
|
# 1641 = ERROR_SUCCESS_REBOOT_INITIATED
|
124
124
|
# 3010 = ERROR_SUCCESS_REBOOT_REQUIRED
|
125
|
-
on host, Command.new("\"#{batch_path}\"", [], { :
|
126
|
-
rescue
|
125
|
+
on host, Command.new("\"#{batch_path}\"", [], { cmdexe: true }), acceptable_exit_codes: [0, 1641, 3010]
|
126
|
+
rescue StandardError
|
127
127
|
logger.info(file_contents_on(host, log_file_escaped))
|
128
128
|
raise
|
129
129
|
end
|
130
130
|
|
131
|
-
if opts[:debug]
|
132
|
-
logger.info(file_contents_on(host, log_file_escaped))
|
133
|
-
end
|
131
|
+
logger.info(file_contents_on(host, log_file_escaped)) if opts[:debug]
|
134
132
|
|
135
133
|
unless host.is_cygwin?
|
136
134
|
# Enable the PATH updates
|
137
135
|
host.close
|
138
136
|
|
139
137
|
# Some systems require a full reboot to trigger the enabled path
|
140
|
-
unless on(host, Command.new('puppet -h', [], { :
|
141
|
-
|
142
|
-
end
|
138
|
+
host.reboot unless on(host, Command.new('puppet -h', [], { cmdexe: true }),
|
139
|
+
accept_all_exit_codes: true).exit_code == 0
|
143
140
|
end
|
144
141
|
|
145
142
|
# verify service status post install
|
@@ -149,18 +146,18 @@ module Beaker
|
|
149
146
|
#
|
150
147
|
# We also take advantage of this output to verify the startup
|
151
148
|
# settings are honored as supplied to the MSI
|
152
|
-
on host, Command.new(
|
149
|
+
on host, Command.new('sc qc puppet || sc qc pe-puppet', [], { cmdexe: true }) do |result|
|
153
150
|
output = result.stdout
|
154
151
|
startup_mode = msi_opts['PUPPET_AGENT_STARTUP_MODE'].upcase
|
155
152
|
|
156
153
|
search = case startup_mode
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
154
|
+
when 'AUTOMATIC'
|
155
|
+
{ code: 2, name: 'AUTO_START' }
|
156
|
+
when 'MANUAL'
|
157
|
+
{ code: 3, name: 'DEMAND_START' }
|
158
|
+
when 'DISABLED'
|
159
|
+
{ code: 4, name: 'DISABLED' }
|
160
|
+
end
|
164
161
|
|
165
162
|
if output !~ /^\s+START_TYPE\s+:\s+#{search[:code]}\s+#{search[:name]}/
|
166
163
|
raise "puppet service startup mode did not match supplied MSI option '#{startup_mode}'"
|
@@ -169,10 +166,13 @@ module Beaker
|
|
169
166
|
|
170
167
|
# (PA-514) value for PUPPET_AGENT_STARTUP_MODE should be present in
|
171
168
|
# registry and honored after install/upgrade.
|
172
|
-
reg_key = host.is_x86_64?
|
173
|
-
|
174
|
-
|
175
|
-
|
169
|
+
reg_key = if host.is_x86_64?
|
170
|
+
'HKLM\\SOFTWARE\\Wow6432Node\\Puppet Labs\\PuppetInstaller'
|
171
|
+
else
|
172
|
+
'HKLM\\SOFTWARE\\Puppet Labs\\PuppetInstaller'
|
173
|
+
end
|
174
|
+
reg_query_command = %(reg query "#{reg_key}" /v "RememberedPuppetAgentStartupMode" | findstr #{msi_opts['PUPPET_AGENT_STARTUP_MODE']})
|
175
|
+
on host, Command.new(reg_query_command, [], { cmdexe: true })
|
176
176
|
|
177
177
|
# emit the misc/versions.txt file which contains component versions for
|
178
178
|
# puppet, facter, hiera, pxp-agent, packaging and vendored Ruby
|
@@ -180,7 +180,7 @@ module Beaker
|
|
180
180
|
"'%PROGRAMFILES%\\Puppet Labs\\puppet\\misc\\versions.txt'",
|
181
181
|
"'%PROGRAMFILES(X86)%\\Puppet Labs\\puppet\\misc\\versions.txt'",
|
182
182
|
].each do |path|
|
183
|
-
result = on(host, "cmd /c type #{path}", :
|
183
|
+
result = on(host, "cmd /c type #{path}", accept_all_exit_codes: true)
|
184
184
|
if result.exit_code == 0
|
185
185
|
logger.info(result.stdout)
|
186
186
|
break
|
@@ -203,25 +203,23 @@ module Beaker
|
|
203
203
|
#
|
204
204
|
# @api private
|
205
205
|
def generic_install_msi_on(hosts, msi_path, msi_opts = {}, opts = {})
|
206
|
-
block_on hosts do |
|
206
|
+
block_on hosts do |host|
|
207
207
|
batch_path, log_file = create_install_msi_batch_on(host, msi_path, msi_opts)
|
208
208
|
# Powershell command looses an escaped slash resulting in cygwin relative path
|
209
209
|
# See https://github.com/puppetlabs/beaker/pull/1626#issuecomment-621341555
|
210
|
-
log_file_escaped = log_file.gsub('\\','\\\\\\')
|
210
|
+
log_file_escaped = log_file.gsub('\\', '\\\\\\')
|
211
211
|
# begin / rescue here so that we can reuse existing error msg propagation
|
212
212
|
begin
|
213
213
|
# 1641 = ERROR_SUCCESS_REBOOT_INITIATED
|
214
214
|
# 3010 = ERROR_SUCCESS_REBOOT_REQUIRED
|
215
|
-
on host, Command.new("\"#{batch_path}\"", [], { :
|
216
|
-
rescue
|
215
|
+
on host, Command.new("\"#{batch_path}\"", [], { cmdexe: true }), acceptable_exit_codes: [0, 1641, 3010]
|
216
|
+
rescue StandardError
|
217
217
|
logger.info(file_contents_on(host, log_file_escaped))
|
218
218
|
|
219
219
|
raise
|
220
220
|
end
|
221
221
|
|
222
|
-
if opts[:debug]
|
223
|
-
logger.info(file_contents_on(host, log_file_escaped))
|
224
|
-
end
|
222
|
+
logger.info(file_contents_on(host, log_file_escaped)) if opts[:debug]
|
225
223
|
|
226
224
|
host.close unless host.is_cygwin?
|
227
225
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Beaker
|
2
2
|
module DSL
|
3
3
|
module Wrappers
|
4
|
-
|
5
4
|
# This is hairy and because of legacy code it will take a bit more
|
6
5
|
# work to disentangle all of the things that are being passed into
|
7
6
|
# this catchall param.
|
@@ -10,7 +9,7 @@ module Beaker
|
|
10
9
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
11
10
|
options['ENV'] ||= {}
|
12
11
|
options[:cmdexe] = true
|
13
|
-
Command.new('facter', args, options
|
12
|
+
Command.new('facter', args, options)
|
14
13
|
end
|
15
14
|
|
16
15
|
# This is hairy and because of legacy code it will take a bit more
|
@@ -21,7 +20,7 @@ module Beaker
|
|
21
20
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
22
21
|
options['ENV'] ||= {}
|
23
22
|
options[:cmdexe] = true
|
24
|
-
Command.new('cfacter', args, options
|
23
|
+
Command.new('cfacter', args, options)
|
25
24
|
end
|
26
25
|
|
27
26
|
# This is hairy and because of legacy code it will take a bit more
|
@@ -32,7 +31,7 @@ module Beaker
|
|
32
31
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
33
32
|
options['ENV'] ||= {}
|
34
33
|
options[:cmdexe] = true
|
35
|
-
Command.new('hiera', args, options
|
34
|
+
Command.new('hiera', args, options)
|
36
35
|
end
|
37
36
|
|
38
37
|
# This is hairy and because of legacy code it will take a bit more
|
@@ -46,48 +45,48 @@ module Beaker
|
|
46
45
|
# we assume that an invocation with `puppet()` will have it's first argument
|
47
46
|
# a face or sub command
|
48
47
|
cmd = "puppet #{args.shift}"
|
49
|
-
Command.new(
|
48
|
+
Command.new(cmd, args, options)
|
50
49
|
end
|
51
50
|
|
52
51
|
# @!visibility private
|
53
52
|
def puppet_resource(*args)
|
54
|
-
puppet(
|
53
|
+
puppet('resource', *args)
|
55
54
|
end
|
56
55
|
|
57
56
|
# @!visibility private
|
58
57
|
def puppet_doc(*args)
|
59
|
-
puppet(
|
58
|
+
puppet('doc', *args)
|
60
59
|
end
|
61
60
|
|
62
61
|
# @!visibility private
|
63
62
|
def puppet_kick(*args)
|
64
|
-
puppet(
|
63
|
+
puppet('kick', *args)
|
65
64
|
end
|
66
65
|
|
67
66
|
# @!visibility private
|
68
67
|
def puppet_cert(*args)
|
69
|
-
puppet(
|
68
|
+
puppet('cert', *args)
|
70
69
|
end
|
71
70
|
|
72
71
|
# @!visibility private
|
73
72
|
def puppet_apply(*args)
|
74
|
-
puppet(
|
73
|
+
puppet('apply', *args)
|
75
74
|
end
|
76
75
|
|
77
76
|
# @!visibility private
|
78
77
|
def puppet_master(*args)
|
79
|
-
puppet(
|
78
|
+
puppet('master', *args)
|
80
79
|
end
|
81
80
|
|
82
81
|
# @!visibility private
|
83
82
|
def puppet_agent(*args)
|
84
|
-
puppet(
|
83
|
+
puppet('agent', *args)
|
85
84
|
end
|
86
85
|
|
87
86
|
# @!visibility private
|
88
87
|
def puppet_filebucket(*args)
|
89
|
-
puppet(
|
88
|
+
puppet('filebucket', *args)
|
90
89
|
end
|
91
90
|
end
|
92
91
|
end
|
93
|
-
end
|
92
|
+
end
|
data/lib/beaker-puppet.rb
CHANGED
@@ -6,19 +6,18 @@ require 'beaker-puppet/wrappers'
|
|
6
6
|
|
7
7
|
require 'beaker-puppet/helpers/rake_helpers'
|
8
8
|
|
9
|
-
[
|
9
|
+
%w[aio foss].each do |lib|
|
10
10
|
require "beaker-puppet/install_utils/#{lib}_defaults"
|
11
11
|
end
|
12
|
-
[
|
12
|
+
%w[windows foss puppet ezbake module].each do |lib|
|
13
13
|
require "beaker-puppet/install_utils/#{lib}_utils"
|
14
14
|
end
|
15
|
-
[
|
15
|
+
%w[tk facter puppet host].each do |lib|
|
16
16
|
require "beaker-puppet/helpers/#{lib}_helpers"
|
17
17
|
end
|
18
18
|
|
19
19
|
require 'beaker-puppet/install_utils/puppet5'
|
20
20
|
|
21
|
-
|
22
21
|
module BeakerPuppet
|
23
22
|
include Beaker::DSL::InstallUtils::FOSSDefaults
|
24
23
|
include Beaker::DSL::InstallUtils::AIODefaults
|
@@ -40,4 +39,4 @@ module BeakerPuppet
|
|
40
39
|
end
|
41
40
|
|
42
41
|
# Register the DSL extension
|
43
|
-
Beaker::DSL.register(
|
42
|
+
Beaker::DSL.register(BeakerPuppet)
|
data/release-prep.sh
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Update Gemfile.lock
|
4
|
+
docker run -t --rm \
|
5
|
+
-v $(pwd):/app \
|
6
|
+
ruby:3.1.4 \
|
7
|
+
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends git make netbase && cd /app && gem install bundler && bundle install --jobs 3; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'
|
8
|
+
|
9
|
+
docker run -t --rm -e CHANGELOG_GITHUB_TOKEN -v $(pwd):/usr/local/src/your-app \
|
10
|
+
githubchangeloggenerator/github-changelog-generator:1.16.2 \
|
11
|
+
github_changelog_generator --future-release $(grep VERSION lib/beaker-puppet/version.rb |rev |cut -d "'" -f 2 |rev)
|
@@ -1,17 +1,30 @@
|
|
1
|
-
test_name
|
1
|
+
test_name 'Install Puppet Agent Packages' do
|
2
|
+
agents.each do |agent|
|
3
|
+
path = ENV.fetch('DEV_BUILD_PATH', nil)
|
4
|
+
if path
|
5
|
+
raise ArgumentError, "The path #{path} does not exist" unless File.exist?(path)
|
6
|
+
|
7
|
+
basename = File.basename(path)
|
8
|
+
scp_to(agent, path, basename)
|
2
9
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
# configure locations for ruby, puppet, config files, etc
|
11
|
+
add_aio_defaults_on(agent)
|
12
|
+
agent.install_package(basename)
|
13
|
+
else
|
14
|
+
opts = {
|
15
|
+
nightly_builds_url: ENV.fetch('NIGHTLY_BUILDS_URL', nil),
|
16
|
+
dev_builds_url: ENV.fetch('DEV_BUILDS_URL', nil),
|
17
|
+
puppet_agent_version: ENV.fetch('SHA', nil),
|
18
|
+
puppet_collection: ENV.fetch('RELEASE_STREAM', nil),
|
19
|
+
}
|
9
20
|
|
10
|
-
|
21
|
+
install_puppet_agent_on(hosts, opts)
|
22
|
+
end
|
23
|
+
end
|
11
24
|
|
12
25
|
# make sure install is sane, beaker has already added puppet and ruby
|
13
26
|
# to PATH in ~/.ssh/environment
|
14
|
-
agents.each do |agent|
|
27
|
+
agents.each do |agent| # rubocop:disable Style/CombinableLoops
|
15
28
|
on agent, puppet('--version')
|
16
29
|
ruby = ruby_command(agent)
|
17
30
|
on agent, "#{ruby} --version"
|
@@ -1,11 +1,9 @@
|
|
1
|
-
test_name
|
1
|
+
test_name 'Expunge puppet bits if hypervisor is none'
|
2
2
|
|
3
3
|
# Ensure that the any previous installations of puppet
|
4
4
|
# are removed from the host if it is not managed by a
|
5
5
|
# provisioning hypervisor.
|
6
6
|
|
7
7
|
hosts.each do |host|
|
8
|
-
if host[:hypervisor] ==
|
9
|
-
remove_puppet_on(host)
|
10
|
-
end
|
8
|
+
remove_puppet_on(host) if host[:hypervisor] == 'none'
|
11
9
|
end
|