beaker 3.37.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -1
- data/acceptance/lib/helpers/test_helper.rb +0 -28
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +106 -103
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/install_package_test.rb +1 -50
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +71 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -3
- data/acceptance/tests/base/host/file_test.rb +81 -0
- data/beaker.gemspec +6 -14
- data/docs/how_to/install_puppet.md +2 -0
- data/docs/how_to/the_beaker_dsl.md +150 -150
- data/docs/how_to/upgrade_from_3_to_4.md +52 -0
- data/lib/beaker.rb +0 -10
- data/lib/beaker/dsl.rb +7 -0
- data/lib/beaker/dsl/helpers.rb +4 -6
- data/lib/beaker/dsl/helpers/host_helpers.rb +10 -34
- data/lib/beaker/dsl/install_utils.rb +0 -5
- data/lib/beaker/dsl/roles.rb +1 -1
- data/lib/beaker/host.rb +12 -11
- data/lib/beaker/host/aix/file.rb +2 -2
- data/lib/beaker/host/aix/group.rb +1 -0
- data/lib/beaker/host/aix/user.rb +1 -0
- data/lib/beaker/host/freebsd/pkg.rb +9 -0
- data/lib/beaker/host/mac/group.rb +1 -0
- data/lib/beaker/host/mac/user.rb +8 -13
- data/lib/beaker/host/pswindows/file.rb +2 -2
- data/lib/beaker/host/pswindows/group.rb +1 -0
- data/lib/beaker/host/pswindows/user.rb +1 -0
- data/lib/beaker/host/unix/exec.rb +5 -5
- data/lib/beaker/host/unix/file.rb +43 -2
- data/lib/beaker/host/unix/group.rb +1 -0
- data/lib/beaker/host/unix/user.rb +1 -0
- data/lib/beaker/host/windows/file.rb +32 -2
- data/lib/beaker/host/windows/group.rb +1 -0
- data/lib/beaker/host/windows/user.rb +1 -0
- data/lib/beaker/host_prebuilt_steps.rb +0 -4
- data/lib/beaker/hypervisor.rb +1 -5
- data/lib/beaker/result.rb +4 -0
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +14 -51
- data/spec/beaker/dsl/wrappers_spec.rb +0 -46
- data/spec/beaker/host/mac/user_spec.rb +5 -8
- data/spec/beaker/host/unix/exec_spec.rb +1 -1
- data/spec/beaker/host/unix/file_spec.rb +39 -0
- data/spec/beaker/host/windows/file_spec.rb +55 -0
- data/spec/beaker/host_prebuilt_steps_spec.rb +16 -67
- data/spec/beaker/host_spec.rb +10 -14
- data/spec/beaker/hypervisor/hypervisor_spec.rb +1 -1
- metadata +47 -165
- data/acceptance/lib/beaker/acceptance/install_utils.rb +0 -58
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_tmpdir_on_test.rb +0 -68
- data/acceptance/tests/base/dsl/install_utils/clone_git_repo_on_test.rb +0 -49
- data/lib/beaker/dsl/helpers/facter_helpers.rb +0 -57
- data/lib/beaker/dsl/install_utils/pe_defaults.rb +0 -143
- data/lib/beaker/dsl/install_utils/windows_utils.rb +0 -223
- data/spec/beaker/dsl/ezbake_utils_spec.rb +0 -279
- data/spec/beaker/dsl/install_utils/pe_defaults_spec.rb +0 -61
- data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +0 -263
@@ -1,49 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib'))
|
3
|
-
|
4
|
-
require 'helpers/test_helper'
|
5
|
-
|
6
|
-
require 'beaker/acceptance/install_utils'
|
7
|
-
extend Beaker::Acceptance::InstallUtils
|
8
|
-
end
|
9
|
-
|
10
|
-
confine :except, :platform => /^solaris-10/
|
11
|
-
|
12
|
-
test_name 'Clone from git' do
|
13
|
-
|
14
|
-
PACKAGES = {
|
15
|
-
:redhat => [
|
16
|
-
'git',
|
17
|
-
],
|
18
|
-
:debian => [
|
19
|
-
['git', 'git-core'],
|
20
|
-
],
|
21
|
-
:solaris_11 => [
|
22
|
-
['git', 'developer/versioning/git'],
|
23
|
-
],
|
24
|
-
:solaris_10 => [
|
25
|
-
'coreutils',
|
26
|
-
'curl', # update curl to fix "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!" issue
|
27
|
-
'git',
|
28
|
-
],
|
29
|
-
:windows => [
|
30
|
-
'git',
|
31
|
-
],
|
32
|
-
:sles => [
|
33
|
-
'git-core',
|
34
|
-
]
|
35
|
-
}
|
36
|
-
|
37
|
-
install_packages_on(hosts, PACKAGES, :check_if_exists => true)
|
38
|
-
|
39
|
-
# implicitly tests build_giturl() and lookup_in_env()
|
40
|
-
hosts.each do |host|
|
41
|
-
on host, "echo #{GitHubSig} >> $HOME/.ssh/known_hosts"
|
42
|
-
testdir = tmpdir_on(host, File.basename(__FILE__))
|
43
|
-
|
44
|
-
step 'should be able to successfully clone a git repo' do
|
45
|
-
results = clone_git_repo_on(host, "#{testdir}", extract_repo_info_from(build_git_url('hiera')))
|
46
|
-
assert_match( %r{From.*github\.com[:/]puppetlabs/hiera}, result.output, 'Did not find clone')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
module Beaker
|
2
|
-
module DSL
|
3
|
-
module Helpers
|
4
|
-
# Methods that help you interact with your facter installation, facter must be installed
|
5
|
-
# for these methods to execute correctly
|
6
|
-
#
|
7
|
-
module FacterHelpers
|
8
|
-
|
9
|
-
# @!macro [new] common_opts
|
10
|
-
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
11
|
-
# @option opts [Boolean] :silent (false) Do not produce log output
|
12
|
-
# @option opts [Array<Fixnum>] :acceptable_exit_codes ([0]) An array
|
13
|
-
# (or range) of integer exit codes that should be considered
|
14
|
-
# acceptable. An error will be thrown if the exit code does not
|
15
|
-
# match one of the values in this list.
|
16
|
-
# @option opts [Boolean] :accept_all_exit_codes (false) Consider all
|
17
|
-
# exit codes as passing.
|
18
|
-
# @option opts [Boolean] :dry_run (false) Do not actually execute any
|
19
|
-
# commands on the SUT
|
20
|
-
# @option opts [String] :stdin (nil) Input to be provided during command
|
21
|
-
# execution on the SUT.
|
22
|
-
# @option opts [Boolean] :pty (false) Execute this command in a pseudoterminal.
|
23
|
-
# @option opts [Boolean] :expect_connection_failure (false) Expect this command
|
24
|
-
# to result in a connection failure, reconnect and continue execution.
|
25
|
-
# @option opts [Hash{String=>String}] :environment ({}) These will be
|
26
|
-
# treated as extra environment variables that should be set before
|
27
|
-
# running the command.
|
28
|
-
#
|
29
|
-
|
30
|
-
# Get a facter fact from a provided host
|
31
|
-
#
|
32
|
-
# @param [Host, Array<Host>, String, Symbol] host One or more hosts to act upon,
|
33
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
34
|
-
# @param [String] name The name of the fact to query for
|
35
|
-
# @!macro common_opts
|
36
|
-
#
|
37
|
-
# @return String The value of the fact 'name' on the provided host
|
38
|
-
# @raise [FailTest] Raises an exception if call to facter fails
|
39
|
-
def fact_on(host, name, opts = {})
|
40
|
-
result = on host, facter(name, opts)
|
41
|
-
if result.kind_of?(Array)
|
42
|
-
result.map { |res| res.stdout.chomp }
|
43
|
-
else
|
44
|
-
result.stdout.chomp
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# Get a facter fact from the default host
|
49
|
-
# @see #fact_on
|
50
|
-
def fact(name, opts = {})
|
51
|
-
fact_on(default, name, opts)
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,143 +0,0 @@
|
|
1
|
-
module Beaker
|
2
|
-
module DSL
|
3
|
-
module InstallUtils
|
4
|
-
#
|
5
|
-
# This module contains default values for pe paths and directorys per-platform
|
6
|
-
#
|
7
|
-
module PEDefaults
|
8
|
-
|
9
|
-
#Here be the pathing and default values for PE installs
|
10
|
-
#
|
11
|
-
PE_DEFAULTS = {
|
12
|
-
'mac' => {
|
13
|
-
'puppetserver-confdir' => '/etc/puppetlabs/puppetserver/conf.d',
|
14
|
-
'puppetservice' => 'pe-puppetserver',
|
15
|
-
'puppetpath' => '/etc/puppetlabs/puppet',
|
16
|
-
'puppetconfdir' => '/etc/puppetlabs/puppet',
|
17
|
-
'puppetcodedir' => '/etc/puppetlabs/puppet',
|
18
|
-
'puppetbin' => '/opt/puppet/bin/puppet',
|
19
|
-
'puppetbindir' => '/opt/puppet/bin',
|
20
|
-
'puppetsbindir' => '/opt/puppet/sbin',
|
21
|
-
'puppetvardir' => '/var/opt/lib/pe-puppet',
|
22
|
-
'hieradatadir' => '/var/lib/hiera',
|
23
|
-
'hieraconf' => '/etc/puppetlabs/puppet/hiera.yaml',
|
24
|
-
'distmoduledir' => '/etc/puppetlabs/puppet/modules',
|
25
|
-
'sitemoduledir' => '/opt/puppet/share/puppet/modules',
|
26
|
-
},
|
27
|
-
'unix' => {
|
28
|
-
'puppetserver-confdir' => '/etc/puppetlabs/puppetserver/conf.d',
|
29
|
-
'puppetservice' => 'pe-puppetserver',
|
30
|
-
'puppetpath' => '/etc/puppetlabs/puppet',
|
31
|
-
'puppetconfdir' => '/etc/puppetlabs/puppet',
|
32
|
-
'puppetbin' => '/opt/puppet/bin/puppet',
|
33
|
-
'puppetbindir' => '/opt/puppet/bin',
|
34
|
-
'puppetsbindir' => '/opt/puppet/sbin',
|
35
|
-
'privatebindir' => '/opt/puppet/bin',
|
36
|
-
'puppetvardir' => '/var/opt/lib/pe-puppet',
|
37
|
-
'hieradatadir' => '/var/lib/hiera',
|
38
|
-
'hieraconf' => '/etc/puppetlabs/puppet/hiera.yaml',
|
39
|
-
'distmoduledir' => '/etc/puppetlabs/puppet/modules',
|
40
|
-
'sitemoduledir' => '/opt/puppet/share/puppet/modules',
|
41
|
-
},
|
42
|
-
'windows' => { #cygwin windows
|
43
|
-
'puppetservice' => 'pe-puppetserver',
|
44
|
-
'puppetpath' => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
|
45
|
-
'puppetconfdir' => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
|
46
|
-
'puppetcodedir' => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
|
47
|
-
'hieraconf' => '`cygpath -smF 35`/Puppetlabs/puppet/etc/hiera.yaml',
|
48
|
-
'puppetvardir' => '`cygpath -smF 35`/PuppetLabs/puppet/var',
|
49
|
-
'distmoduledir' => '`cygpath -smF 35`/PuppetLabs/puppet/etc/modules',
|
50
|
-
'sitemoduledir' => 'C:/usr/share/puppet/modules',
|
51
|
-
#let's just add both potential bin dirs to the path
|
52
|
-
'puppetbindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet Enterprise/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet Enterprise/bin',
|
53
|
-
'privatebindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet Enterprise/sys/ruby/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet Enterprise/sys/ruby/bin',
|
54
|
-
},
|
55
|
-
'pswindows' => { #windows windows
|
56
|
-
'puppetservice' => 'pe-puppetserver',
|
57
|
-
'puppetpath' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
|
58
|
-
'puppetconfdir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
|
59
|
-
'puppetcodedir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc',
|
60
|
-
'hieraconf' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\hiera.yaml',
|
61
|
-
'distmoduledir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules',
|
62
|
-
'sitemoduledir' => 'C:\\usr\\share\\puppet\\modules',
|
63
|
-
'puppetvardir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\var',
|
64
|
-
'puppetbindir' => '"C:\\Program Files (x86)\\PuppetLabs\\Puppet Enterprise\\bin";"C:\\Program Files\\PuppetLabs\\Puppet Enterprise\\bin"'
|
65
|
-
},
|
66
|
-
}
|
67
|
-
|
68
|
-
# Add the appropriate pe defaults to the host object so that they can be accessed using host[option], set host[:type] = pe
|
69
|
-
# @param [Host] host A single host to act upon
|
70
|
-
# @param [String] platform The platform type of this host, one of windows, pswindows, mac & unix
|
71
|
-
def add_platform_pe_defaults(host, platform)
|
72
|
-
PE_DEFAULTS[platform].each_pair do |key, val|
|
73
|
-
host[key] = val
|
74
|
-
end
|
75
|
-
# add the type and group here for backwards compatability
|
76
|
-
if host['platform'] =~ /windows/
|
77
|
-
host['group'] = 'Administrators'
|
78
|
-
else
|
79
|
-
host['group'] = 'pe-puppet'
|
80
|
-
end
|
81
|
-
host['type'] = 'pe'
|
82
|
-
# older pe requires a different puppetservice name, set it here on the master
|
83
|
-
if host['roles'].include?('master')
|
84
|
-
if host['pe_ver'] and (version_is_less(host['pe_ver'], '3.4'))
|
85
|
-
host['puppetservice'] = 'pe-httpd'
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# Add the appropriate pe defaults to an array of hosts
|
91
|
-
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
92
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
93
|
-
def add_pe_defaults_on(hosts)
|
94
|
-
block_on hosts do | host |
|
95
|
-
case host.class.to_s.downcase
|
96
|
-
when /aix|(free|open)bsd|unix/
|
97
|
-
platform = 'unix'
|
98
|
-
when /mac/
|
99
|
-
platform = 'mac'
|
100
|
-
when /pswindows/
|
101
|
-
platform = 'pswindows'
|
102
|
-
else
|
103
|
-
platform = 'windows'
|
104
|
-
end
|
105
|
-
add_platform_pe_defaults(host, platform)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# Remove the appropriate pe defaults from the host object so that they can no longer be accessed using host[option], set host[:type] = nil
|
110
|
-
# @param [Host] host A single host to act upon
|
111
|
-
# @param [String] platform The platform type of this host, one of windows, freebsd, mac & unix
|
112
|
-
def remove_platform_pe_defaults(host, platform)
|
113
|
-
PE_DEFAULTS[platform].each_pair do |key, val|
|
114
|
-
host.delete(key)
|
115
|
-
end
|
116
|
-
host['group'] = nil
|
117
|
-
host['type'] = nil
|
118
|
-
end
|
119
|
-
|
120
|
-
# Remove the appropriate pe defaults from an array of hosts
|
121
|
-
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
122
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
123
|
-
def remove_pe_defaults_on(hosts)
|
124
|
-
block_on hosts do | host |
|
125
|
-
case host.class.to_s.downcase
|
126
|
-
when /aix|(free|open)bsd|unix/
|
127
|
-
platform = 'unix'
|
128
|
-
when /mac/
|
129
|
-
platform = 'mac'
|
130
|
-
when /pswindows/
|
131
|
-
platform = 'pswindows'
|
132
|
-
else
|
133
|
-
platform = 'windows'
|
134
|
-
end
|
135
|
-
remove_platform_pe_defaults(host, platform)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
@@ -1,223 +0,0 @@
|
|
1
|
-
module Beaker
|
2
|
-
module DSL
|
3
|
-
module InstallUtils
|
4
|
-
#
|
5
|
-
# This module contains methods useful for Windows installs
|
6
|
-
#
|
7
|
-
module WindowsUtils
|
8
|
-
# Given a host, returns it's system TEMP path
|
9
|
-
#
|
10
|
-
# @param [Host] host An object implementing {Beaker::Hosts}'s interface.
|
11
|
-
#
|
12
|
-
# @return [String] system temp path
|
13
|
-
def get_system_temp_path(host)
|
14
|
-
host.system_temp_path
|
15
|
-
end
|
16
|
-
alias_method :get_temp_path, :get_system_temp_path
|
17
|
-
|
18
|
-
# Generates commands to be inserted into a Windows batch file to launch an MSI install
|
19
|
-
# @param [String] msi_path The path of the MSI - can be a local Windows style file path like
|
20
|
-
# c:\temp\puppet.msi OR a url like https://download.com/puppet.msi or file://c:\temp\puppet.msi
|
21
|
-
# @param [Hash{String=>String}] msi_opts MSI installer options
|
22
|
-
# See https://docs.puppetlabs.com/guides/install_puppet/install_windows.html#msi-properties
|
23
|
-
# @param [String] log_path The path to write the MSI log - must be a local Windows style file path
|
24
|
-
#
|
25
|
-
# @api private
|
26
|
-
def msi_install_script(msi_path, msi_opts, log_path)
|
27
|
-
# msiexec requires backslashes in file paths launched under cmd.exe start /w
|
28
|
-
url_pattern = /^(https?|file):\/\//
|
29
|
-
msi_path = msi_path.gsub(/\//, "\\") if msi_path !~ url_pattern
|
30
|
-
|
31
|
-
msi_params = msi_opts.map{|k, v| "#{k}=#{v}"}.join(' ')
|
32
|
-
|
33
|
-
# msiexec requires quotes around paths with backslashes - c:\ or file://c:\
|
34
|
-
# not strictly needed for http:// but it simplifies this code
|
35
|
-
batch_contents = <<-BATCH
|
36
|
-
start /w msiexec.exe /i \"#{msi_path}\" /qn /L*V #{log_path} #{msi_params}
|
37
|
-
exit /B %errorlevel%
|
38
|
-
BATCH
|
39
|
-
end
|
40
|
-
|
41
|
-
# Given a host, path to MSI and MSI options, will create a batch file
|
42
|
-
# on the host, returning the path to the randomized batch file and
|
43
|
-
# the randomized log file
|
44
|
-
#
|
45
|
-
# @param [Host] host An object implementing {Beaker::Hosts}'s interface.
|
46
|
-
# @param [String] msi_path The path of the MSI - can be a local Windows
|
47
|
-
# style file path like c:\temp\puppet.msi OR a url like
|
48
|
-
# https://download.com/puppet.msi or file://c:\temp\puppet.msi
|
49
|
-
# @param [Hash{String=>String}] msi_opts MSI installer options
|
50
|
-
# See https://docs.puppetlabs.com/guides/install_puppet/install_windows.html#msi-properties
|
51
|
-
#
|
52
|
-
# @api private
|
53
|
-
# @return [String, String] path to the batch file, patch to the log file
|
54
|
-
def create_install_msi_batch_on(host, msi_path, msi_opts)
|
55
|
-
timestamp = Time.new.strftime('%Y-%m-%d_%H.%M.%S')
|
56
|
-
tmp_path = host.system_temp_path
|
57
|
-
tmp_path.gsub!('/', '\\')
|
58
|
-
|
59
|
-
batch_name = "install-puppet-msi-#{timestamp}.bat"
|
60
|
-
batch_path = "#{tmp_path}#{host.scp_separator}#{batch_name}"
|
61
|
-
log_path = "#{tmp_path}\\install-puppet-#{timestamp}.log"
|
62
|
-
|
63
|
-
Tempfile.open(batch_name) do |tmp_file|
|
64
|
-
batch_contents = msi_install_script(msi_path, msi_opts, log_path)
|
65
|
-
|
66
|
-
File.open(tmp_file.path, 'w') { |file| file.puts(batch_contents) }
|
67
|
-
host.do_scp_to(tmp_file.path, batch_path, {})
|
68
|
-
end
|
69
|
-
|
70
|
-
return batch_path, log_path
|
71
|
-
end
|
72
|
-
|
73
|
-
# Given hosts construct a PATH that includes puppetbindir, facterbindir and hierabindir
|
74
|
-
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
75
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
76
|
-
# @param [String] msi_path The path of the MSI - can be a local Windows style file path like
|
77
|
-
# c:\temp\puppet.msi OR a url like https://download.com/puppet.msi or file://c:\temp\puppet.msi
|
78
|
-
# @param [Hash{String=>String}] msi_opts MSI installer options
|
79
|
-
# See https://docs.puppetlabs.com/guides/install_puppet/install_windows.html#msi-properties
|
80
|
-
# @option msi_opts [String] INSTALLIDIR Where Puppet and its dependencies should be installed.
|
81
|
-
# (Defaults vary based on operating system and intaller architecture)
|
82
|
-
# Requires Puppet 2.7.12 / PE 2.5.0
|
83
|
-
# @option msi_opts [String] PUPPET_MASTER_SERVER The hostname where the puppet master server can be reached.
|
84
|
-
# (Defaults to puppet)
|
85
|
-
# Requires Puppet 2.7.12 / PE 2.5.0
|
86
|
-
# @option msi_opts [String] PUPPET_CA_SERVER The hostname where the CA puppet master server can be reached, if you are using multiple masters and only one of them is acting as the CA.
|
87
|
-
# (Defaults the value of PUPPET_MASTER_SERVER)
|
88
|
-
# Requires Puppet 2.7.12 / PE 2.5.0
|
89
|
-
# @option msi_opts [String] PUPPET_AGENT_CERTNAME The node’s certificate name, and the name it uses when requesting catalogs. This will set a value for
|
90
|
-
# (Defaults to the node's fqdn as discovered by facter fqdn)
|
91
|
-
# Requires Puppet 2.7.12 / PE 2.5.0
|
92
|
-
# @option msi_opts [String] PUPPET_AGENT_ENVIRONMENT The node’s environment.
|
93
|
-
# (Defaults to production)
|
94
|
-
# Requires Puppet 3.3.1 / PE 3.1.0
|
95
|
-
# @option msi_opts [String] PUPPET_AGENT_STARTUP_MODE Whether the puppet agent service should run (or be allowed to run)
|
96
|
-
# (Defaults to Manual - valid values are Automatic, Manual or Disabled)
|
97
|
-
# Requires Puppet 3.4.0 / PE 3.2.0
|
98
|
-
# @option msi_opts [String] PUPPET_AGENT_ACCOUNT_USER Whether the puppet agent service should run (or be allowed to run)
|
99
|
-
# (Defaults to LocalSystem)
|
100
|
-
# Requires Puppet 3.4.0 / PE 3.2.0
|
101
|
-
# @option msi_opts [String] PUPPET_AGENT_ACCOUNT_PASSWORD The password to use for puppet agent’s user account
|
102
|
-
# (No default)
|
103
|
-
# Requires Puppet 3.4.0 / PE 3.2.0
|
104
|
-
# @option msi_opts [String] PUPPET_AGENT_ACCOUNT_DOMAIN The domain of puppet agent’s user account.
|
105
|
-
# (Defaults to .)
|
106
|
-
# Requires Puppet 3.4.0 / PE 3.2.0
|
107
|
-
# @option opts [Boolean] :debug output the MSI installation log when set to true
|
108
|
-
# otherwise do not output log (false; default behavior)
|
109
|
-
#
|
110
|
-
# @example
|
111
|
-
# install_msi_on(hosts, 'c:\puppet.msi', {:debug => true})
|
112
|
-
#
|
113
|
-
# @api private
|
114
|
-
def install_msi_on(hosts, msi_path, msi_opts = {}, opts = {})
|
115
|
-
block_on hosts do | host |
|
116
|
-
msi_opts['PUPPET_AGENT_STARTUP_MODE'] ||= 'Manual'
|
117
|
-
batch_path, log_file = create_install_msi_batch_on(host, msi_path, msi_opts)
|
118
|
-
|
119
|
-
# begin / rescue here so that we can reuse existing error msg propagation
|
120
|
-
begin
|
121
|
-
# 1641 = ERROR_SUCCESS_REBOOT_INITIATED
|
122
|
-
# 3010 = ERROR_SUCCESS_REBOOT_REQUIRED
|
123
|
-
on host, Command.new("\"#{batch_path}\"", [], { :cmdexe => true }), :acceptable_exit_codes => [0, 1641, 3010]
|
124
|
-
rescue
|
125
|
-
on host, Command.new("type \"#{log_file}\"", [], { :cmdexe => true })
|
126
|
-
raise
|
127
|
-
end
|
128
|
-
|
129
|
-
if opts[:debug]
|
130
|
-
on host, Command.new("type \"#{log_file}\"", [], { :cmdexe => true })
|
131
|
-
end
|
132
|
-
|
133
|
-
if !host.is_cygwin?
|
134
|
-
# HACK: for some reason, post install we need to refresh the connection to make puppet available for execution
|
135
|
-
host.close
|
136
|
-
end
|
137
|
-
|
138
|
-
# verify service status post install
|
139
|
-
# if puppet service exists, then pe-puppet is not queried
|
140
|
-
# if puppet service does not exist, pe-puppet is queried and that exit code is used
|
141
|
-
# therefore, this command will always exit 0 if either service is installed
|
142
|
-
#
|
143
|
-
# We also take advantage of this output to verify the startup
|
144
|
-
# settings are honored as supplied to the MSI
|
145
|
-
on host, Command.new("sc qc puppet || sc qc pe-puppet", [], { :cmdexe => true }) do |result|
|
146
|
-
output = result.stdout
|
147
|
-
startup_mode = msi_opts['PUPPET_AGENT_STARTUP_MODE'].upcase
|
148
|
-
|
149
|
-
search = case startup_mode
|
150
|
-
when 'AUTOMATIC'
|
151
|
-
{ :code => 2, :name => 'AUTO_START' }
|
152
|
-
when 'MANUAL'
|
153
|
-
{ :code => 3, :name => 'DEMAND_START' }
|
154
|
-
when 'DISABLED'
|
155
|
-
{ :code => 4, :name => 'DISABLED' }
|
156
|
-
end
|
157
|
-
|
158
|
-
if output !~ /^\s+START_TYPE\s+:\s+#{search[:code]}\s+#{search[:name]}/
|
159
|
-
raise "puppet service startup mode did not match supplied MSI option '#{startup_mode}'"
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
# (PA-514) value for PUPPET_AGENT_STARTUP_MODE should be present in
|
164
|
-
# registry and honored after install/upgrade.
|
165
|
-
reg_key = host.is_x86_64? ? "HKLM\\SOFTWARE\\Wow6432Node\\Puppet Labs\\PuppetInstaller" :
|
166
|
-
"HKLM\\SOFTWARE\\Puppet Labs\\PuppetInstaller"
|
167
|
-
reg_query_command = %Q(reg query "#{reg_key}" /v "RememberedPuppetAgentStartupMode" | findstr #{msi_opts['PUPPET_AGENT_STARTUP_MODE']})
|
168
|
-
on host, Command.new(reg_query_command, [], { :cmdexe => true })
|
169
|
-
|
170
|
-
# emit the misc/versions.txt file which contains component versions for
|
171
|
-
# puppet, facter, hiera, pxp-agent, packaging and vendored Ruby
|
172
|
-
[
|
173
|
-
"\\\"%ProgramFiles%\\Puppet Labs\\puppet\\misc\\versions.txt\\\"",
|
174
|
-
"\\\"%ProgramFiles(x86)%\\Puppet Labs\\puppet\\misc\\versions.txt\\\""
|
175
|
-
].each do |path|
|
176
|
-
on host, Command.new("\"if exist #{path} type #{path}\"", [], { :cmdexe => true })
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
# Installs a specified msi path on given hosts
|
182
|
-
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
183
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
184
|
-
# @param [String] msi_path The path of the MSI - can be a local Windows style file path like
|
185
|
-
# c:\temp\foo.msi OR a url like https://download.com/foo.msi or file://c:\temp\foo.msi
|
186
|
-
# @param [Hash{String=>String}] msi_opts MSI installer options
|
187
|
-
# @option opts [Boolean] :debug output the MSI installation log when set to true
|
188
|
-
# otherwise do not output log (false; default behavior)
|
189
|
-
#
|
190
|
-
# @example
|
191
|
-
# generic_install_msi_on(hosts, 'https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4.msi', {}, {:debug => true})
|
192
|
-
#
|
193
|
-
# @api private
|
194
|
-
def generic_install_msi_on(hosts, msi_path, msi_opts = {}, opts = {})
|
195
|
-
block_on hosts do | host |
|
196
|
-
batch_path, log_file = create_install_msi_batch_on(host, msi_path, msi_opts)
|
197
|
-
|
198
|
-
# begin / rescue here so that we can reuse existing error msg propagation
|
199
|
-
begin
|
200
|
-
# 1641 = ERROR_SUCCESS_REBOOT_INITIATED
|
201
|
-
# 3010 = ERROR_SUCCESS_REBOOT_REQUIRED
|
202
|
-
on host, Command.new("\"#{batch_path}\"", [], { :cmdexe => true }), :acceptable_exit_codes => [0, 1641, 3010]
|
203
|
-
rescue
|
204
|
-
on host, Command.new("type \"#{log_file}\"", [], { :cmdexe => true })
|
205
|
-
raise
|
206
|
-
end
|
207
|
-
|
208
|
-
if opts[:debug]
|
209
|
-
on host, Command.new("type \"#{log_file}\"", [], { :cmdexe => true })
|
210
|
-
end
|
211
|
-
|
212
|
-
if !host.is_cygwin?
|
213
|
-
# HACK: for some reason, post install we need to refresh the connection to make puppet available for execution
|
214
|
-
host.close
|
215
|
-
end
|
216
|
-
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|