beaker 3.18.0 → 3.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Rakefile +0 -23
- data/beaker.gemspec +1 -0
- data/lib/beaker/dsl/helpers.rb +3 -4
- data/lib/beaker/dsl/install_utils.rb +2 -7
- data/lib/beaker/dsl/wrappers.rb +0 -87
- data/lib/beaker/host/unix/pkg.rb +56 -17
- data/lib/beaker/hypervisor/docker.rb +26 -1
- data/lib/beaker/options/parser.rb +12 -5
- data/lib/beaker/options/subcommand_options_file_parser.rb +11 -4
- data/lib/beaker/ssh_connection.rb +6 -6
- data/lib/beaker/subcommand.rb +6 -0
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/host/unix/pkg_spec.rb +130 -0
- data/spec/beaker/hypervisor/docker_spec.rb +28 -1
- data/spec/beaker/options/parser_spec.rb +38 -18
- data/spec/beaker/options/subcommand_options_parser_spec.rb +28 -5
- data/spec/beaker/ssh_connection_spec.rb +17 -17
- metadata +16 -28
- data/acceptance/config/puppetgem/acceptance-options.rb +0 -9
- data/acceptance/config/puppetgit/acceptance-options.rb +0 -9
- data/acceptance/config/puppetpkg/acceptance-options.rb +0 -8
- data/acceptance/pre_suite/puppet_gem/install.rb +0 -8
- data/acceptance/pre_suite/puppet_git/install.rb +0 -98
- data/acceptance/pre_suite/puppet_pkg/install.rb +0 -9
- data/acceptance/tests/puppet/README.md +0 -3
- data/acceptance/tests/puppet/install_smoke_test.rb +0 -21
- data/acceptance/tests/puppet/stub_host.rb +0 -47
- data/acceptance/tests/puppet/web_helpers_test.rb +0 -55
- data/acceptance/tests/puppet/with_puppet_running_on.rb +0 -26
- data/lib/beaker/dsl/helpers/puppet_helpers.rb +0 -865
- data/lib/beaker/dsl/helpers/tk_helpers.rb +0 -89
- data/lib/beaker/dsl/install_utils/aio_defaults.rb +0 -93
- data/lib/beaker/dsl/install_utils/ezbake_utils.rb +0 -256
- data/lib/beaker/dsl/install_utils/foss_defaults.rb +0 -211
- data/lib/beaker/dsl/install_utils/foss_utils.rb +0 -1307
- data/lib/beaker/dsl/install_utils/module_utils.rb +0 -244
- data/lib/beaker/dsl/install_utils/puppet_utils.rb +0 -157
- data/lib/beaker/options/homedir_options_file_parser.rb +0 -0
- data/spec/beaker/dsl/helpers/facter_helpers_spec.rb +0 -59
- data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +0 -1179
- data/spec/beaker/dsl/helpers/tk_helpers_spec.rb +0 -83
- data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +0 -1307
- data/spec/beaker/dsl/install_utils/module_utils_spec.rb +0 -261
- data/spec/beaker/dsl/install_utils/puppet_utils_spec.rb +0 -136
@@ -1,89 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'hocon'
|
3
|
-
require 'hocon/config_error'
|
4
|
-
require 'inifile'
|
5
|
-
|
6
|
-
module Beaker
|
7
|
-
module DSL
|
8
|
-
module Helpers
|
9
|
-
# Convenience methods for modifying and reading TrapperKeeper configs
|
10
|
-
module TKHelpers
|
11
|
-
|
12
|
-
# Modify the given TrapperKeeper config file.
|
13
|
-
#
|
14
|
-
# @param [Host] host A host object
|
15
|
-
# @param [OptionsHash] options_hash New hash which will be merged into
|
16
|
-
# the given TrapperKeeper config.
|
17
|
-
# @param [String] config_file_path Path to the TrapperKeeper config on
|
18
|
-
# the given host which is to be
|
19
|
-
# modified.
|
20
|
-
# @param [Bool] replace If set true, instead of updating the existing
|
21
|
-
# TrapperKeeper configuration, replace it entirely
|
22
|
-
# with the contents of the given hash.
|
23
|
-
#
|
24
|
-
# @note TrapperKeeper config files can be HOCON, JSON, or Ini. We don't
|
25
|
-
# particularly care which of these the file named by `config_file_path` on
|
26
|
-
# the SUT actually is, just that the contents can be parsed into a map.
|
27
|
-
#
|
28
|
-
def modify_tk_config(host, config_file_path, options_hash, replace=false)
|
29
|
-
if options_hash.empty?
|
30
|
-
return nil
|
31
|
-
end
|
32
|
-
|
33
|
-
new_hash = Beaker::Options::OptionsHash.new
|
34
|
-
|
35
|
-
if replace
|
36
|
-
new_hash.merge!(options_hash)
|
37
|
-
else
|
38
|
-
if not host.file_exist?( config_file_path )
|
39
|
-
raise "Error: #{config_file_path} does not exist on #{host}"
|
40
|
-
end
|
41
|
-
file_string = host.exec( Command.new( "cat #{config_file_path}" )).stdout
|
42
|
-
|
43
|
-
begin
|
44
|
-
tk_conf_hash = read_tk_config_string(file_string)
|
45
|
-
rescue RuntimeError
|
46
|
-
raise "Error reading trapperkeeper config: #{config_file_path} at host: #{host}"
|
47
|
-
end
|
48
|
-
|
49
|
-
new_hash.merge!(tk_conf_hash)
|
50
|
-
new_hash.merge!(options_hash)
|
51
|
-
end
|
52
|
-
|
53
|
-
file_string = JSON.pretty_generate(new_hash)
|
54
|
-
create_remote_file host, config_file_path, file_string
|
55
|
-
end
|
56
|
-
|
57
|
-
# The Trapperkeeper config service will accept HOCON (aka typesafe), JSON,
|
58
|
-
# or Ini configuration files which means we need to safely handle the the
|
59
|
-
# exceptions that might come from parsing the given string with the wrong
|
60
|
-
# parser and fall back to the next valid parser in turn. We finally raise
|
61
|
-
# a RuntimeException if none of the parsers succeed.
|
62
|
-
#
|
63
|
-
# @!visibility private
|
64
|
-
def read_tk_config_string( string )
|
65
|
-
begin
|
66
|
-
return Hocon.parse(string)
|
67
|
-
rescue Hocon::ConfigError
|
68
|
-
nil
|
69
|
-
end
|
70
|
-
|
71
|
-
begin
|
72
|
-
return JSON.parse(string)
|
73
|
-
rescue JSON::JSONError
|
74
|
-
nil
|
75
|
-
end
|
76
|
-
|
77
|
-
begin
|
78
|
-
return IniFile.new(content: string)
|
79
|
-
rescue IniFile::Error
|
80
|
-
nil
|
81
|
-
end
|
82
|
-
|
83
|
-
raise "Failed to read TrapperKeeper config!"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
module Beaker
|
2
|
-
module DSL
|
3
|
-
module InstallUtils
|
4
|
-
#
|
5
|
-
# This module contains default values for aio paths and directorys per-platform
|
6
|
-
#
|
7
|
-
module AIODefaults
|
8
|
-
|
9
|
-
#Here be the pathing and default values for AIO installs
|
10
|
-
#
|
11
|
-
AIO_DEFAULTS = {
|
12
|
-
'unix' => {
|
13
|
-
'puppetbindir' => '/opt/puppetlabs/bin',
|
14
|
-
'privatebindir' => '/opt/puppetlabs/puppet/bin',
|
15
|
-
'distmoduledir' => '/etc/puppetlabs/code/modules',
|
16
|
-
'sitemoduledir' => '/opt/puppetlabs/puppet/modules',
|
17
|
-
},
|
18
|
-
'windows' => { #windows
|
19
|
-
'puppetbindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet/bin',
|
20
|
-
'privatebindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/sys/ruby/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet/sys/ruby/bin',
|
21
|
-
'distmoduledir' => '`cygpath -smF 35`/PuppetLabs/code/modules',
|
22
|
-
# sitemoduledir not included (check PUP-4049 for more info)
|
23
|
-
},
|
24
|
-
'pwindows' => { #pure windows
|
25
|
-
'puppetbindir' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\bin";"C:\\Program Files\\Puppet Labs\\Puppet\\bin"',
|
26
|
-
'privatebindir' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\sys\\ruby\\bin";"C:\\Program Files\\Puppet Labs\\Puppet\\sys\\ruby\\bin"',
|
27
|
-
'distmoduledir' => 'C:\\ProgramData\\PuppetLabs\\code\\modules',
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
# Add the appropriate aio defaults to the host object so that they can be accessed using host[option], set host[:type] = aio
|
32
|
-
# @param [Host] host A single host to act upon
|
33
|
-
# @param [String] platform The platform type of this host, one of windows or unix
|
34
|
-
def add_platform_aio_defaults(host, platform)
|
35
|
-
AIO_DEFAULTS[platform].each_pair do |key, val|
|
36
|
-
host[key] = val
|
37
|
-
end
|
38
|
-
# add group and type here for backwards compatability
|
39
|
-
if host['platform'] =~ /windows/
|
40
|
-
host['group'] = 'Administrators'
|
41
|
-
else
|
42
|
-
host['group'] = 'puppet'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Add the appropriate aio defaults to an array of hosts
|
47
|
-
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
48
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
49
|
-
def add_aio_defaults_on(hosts)
|
50
|
-
block_on hosts do | host |
|
51
|
-
if host.is_powershell?
|
52
|
-
platform = 'pwindows'
|
53
|
-
elsif host['platform'] =~ /windows/
|
54
|
-
platform = 'windows'
|
55
|
-
else
|
56
|
-
platform = 'unix'
|
57
|
-
end
|
58
|
-
add_platform_aio_defaults(host, platform)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# Remove the appropriate aio defaults from the host object so that they can no longer be accessed using host[option], set host[:type] = nil
|
63
|
-
# @param [Host] host A single host to act upon
|
64
|
-
# @param [String] platform The platform type of this host, one of windows, pswindows, freebsd, mac & unix
|
65
|
-
def remove_platform_aio_defaults(host, platform)
|
66
|
-
AIO_DEFAULTS[platform].each_pair do |key, val|
|
67
|
-
host.delete(key)
|
68
|
-
end
|
69
|
-
host['group'] = nil
|
70
|
-
end
|
71
|
-
|
72
|
-
# Remove the appropriate aio defaults from an array of hosts
|
73
|
-
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
74
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
75
|
-
def remove_aio_defaults_on(hosts)
|
76
|
-
block_on hosts do | host |
|
77
|
-
if host.is_powershell?
|
78
|
-
platform = 'pswindows'
|
79
|
-
elsif host['platform'] =~ /windows/
|
80
|
-
platform = 'windows'
|
81
|
-
else
|
82
|
-
platform = 'unix'
|
83
|
-
end
|
84
|
-
remove_platform_aio_defaults(host, platform)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
@@ -1,256 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
module Beaker
|
4
|
-
module DSL
|
5
|
-
module InstallUtils
|
6
|
-
# This module contains methods to assist in installing projects from source
|
7
|
-
# that use ezbake for packaging.
|
8
|
-
#
|
9
|
-
module EZBakeUtils
|
10
|
-
|
11
|
-
# @!group Public DSL Methods
|
12
|
-
|
13
|
-
# Installs leiningen project with given name and version on remote host.
|
14
|
-
#
|
15
|
-
# @param [Host] host A single remote host on which to install the
|
16
|
-
# specified leiningen project.
|
17
|
-
def install_from_ezbake host
|
18
|
-
ezbake_validate_support host
|
19
|
-
ezbake_tools_available?
|
20
|
-
install_ezbake_tarball_on_host host
|
21
|
-
ezbake_installsh host, "service"
|
22
|
-
end
|
23
|
-
|
24
|
-
# Installs termini with given name and version on remote host.
|
25
|
-
#
|
26
|
-
# @param [Host] host A single remote host on which to install the
|
27
|
-
# specified leiningen project.
|
28
|
-
def install_termini_from_ezbake host
|
29
|
-
ezbake_validate_support host
|
30
|
-
ezbake_tools_available?
|
31
|
-
install_ezbake_tarball_on_host host
|
32
|
-
ezbake_installsh host, "termini"
|
33
|
-
end
|
34
|
-
|
35
|
-
# Install a development version of ezbake into the local m2 repository
|
36
|
-
#
|
37
|
-
# This can be useful if you want to work on a development branch of
|
38
|
-
# ezbake that hasn't been released yet. Ensure your project dependencies
|
39
|
-
# in your development branch include a reference to the -SNAPSHOT
|
40
|
-
# version of the project for it to successfully pickup a pre-shipped
|
41
|
-
# version of ezbake.
|
42
|
-
#
|
43
|
-
# @param url [String] git url
|
44
|
-
# @param branch [String] git branch
|
45
|
-
def ezbake_dev_build url = "git@github.com:puppetlabs/ezbake.git",
|
46
|
-
branch = "master"
|
47
|
-
ezbake_dir = 'tmp/ezbake'
|
48
|
-
conditionally_clone url, ezbake_dir, branch
|
49
|
-
lp = ezbake_lein_prefix
|
50
|
-
|
51
|
-
Dir.chdir(ezbake_dir) do
|
52
|
-
ezbake_local_cmd "#{lp} install",
|
53
|
-
:throw_on_failure => true
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# @!endgroup
|
58
|
-
|
59
|
-
class << self
|
60
|
-
attr_accessor :config
|
61
|
-
end
|
62
|
-
|
63
|
-
# @!group Private helpers
|
64
|
-
|
65
|
-
# Test for support in one place
|
66
|
-
#
|
67
|
-
# @param [Host] host host to check for support
|
68
|
-
# @raise [RuntimeError] if OS is not supported
|
69
|
-
# @api private
|
70
|
-
def ezbake_validate_support host
|
71
|
-
variant, version, _, _ = host['platform'].to_array
|
72
|
-
unless variant =~ /^(fedora|el|centos|debian|ubuntu)$/
|
73
|
-
raise RuntimeError,
|
74
|
-
"No support for #{variant} within ezbake_utils ..."
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
# Build, copy & unpack tarball on remote host
|
79
|
-
#
|
80
|
-
# @param [Host] host installation destination
|
81
|
-
# @api private
|
82
|
-
def install_ezbake_tarball_on_host host
|
83
|
-
if not ezbake_config
|
84
|
-
ezbake_stage
|
85
|
-
end
|
86
|
-
|
87
|
-
# Skip installation if the remote directory exists
|
88
|
-
result = on host, "test -d #{ezbake_install_dir}", :acceptable_exit_codes => [0, 1]
|
89
|
-
return if result.exit_code == 0
|
90
|
-
|
91
|
-
ezbake_staging_dir = File.join('target', 'staging')
|
92
|
-
Dir.chdir(ezbake_staging_dir) do
|
93
|
-
ezbake_local_cmd 'rake package:tar'
|
94
|
-
end
|
95
|
-
|
96
|
-
local_tarball = ezbake_staging_dir + "/pkg/" + ezbake_install_name + ".tar.gz"
|
97
|
-
remote_tarball = ezbake_install_dir + ".tar.gz"
|
98
|
-
scp_to host, local_tarball, remote_tarball
|
99
|
-
|
100
|
-
# untar tarball on host
|
101
|
-
on host, "tar -xzf " + remote_tarball
|
102
|
-
|
103
|
-
# Check to ensure directory exists
|
104
|
-
on host, "test -d #{ezbake_install_dir}"
|
105
|
-
end
|
106
|
-
|
107
|
-
LOCAL_COMMANDS_REQUIRED = [
|
108
|
-
['leiningen', 'lein --version', nil],
|
109
|
-
['lein-pprint', 'lein with-profile ci pprint :version',
|
110
|
-
'Must have lein-pprint installed under the :ci profile.'],
|
111
|
-
['java', 'java -version', nil],
|
112
|
-
['git', 'git --version', nil],
|
113
|
-
['rake', 'rake --version', nil],
|
114
|
-
]
|
115
|
-
|
116
|
-
# Checks given host for the tools necessary to perform
|
117
|
-
# install_from_ezbake.
|
118
|
-
#
|
119
|
-
# @raise [RuntimeError] if tool is not found
|
120
|
-
# @api private
|
121
|
-
def ezbake_tools_available?
|
122
|
-
LOCAL_COMMANDS_REQUIRED.each do |software_name, command, additional_error_message|
|
123
|
-
if not system command
|
124
|
-
error_message = "Must have #{software_name} installed on development system.\n"
|
125
|
-
if additional_error_message
|
126
|
-
error_message += additional_error_message
|
127
|
-
end
|
128
|
-
raise RuntimeError, error_message
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
# Return the ezbake config.
|
134
|
-
#
|
135
|
-
# @return [Hash] configuration for ezbake, usually from ezbake.rb
|
136
|
-
# @api private
|
137
|
-
def ezbake_config
|
138
|
-
EZBakeUtils.config
|
139
|
-
end
|
140
|
-
|
141
|
-
# Returns a leiningen prefix with local m2 repo capability
|
142
|
-
#
|
143
|
-
# @return [String] lein prefix command that uses a local build
|
144
|
-
# m2 repository.
|
145
|
-
# @api private
|
146
|
-
def ezbake_lein_prefix
|
147
|
-
# Get the absolute path to the local repo
|
148
|
-
m2_repo = File.join(Dir.pwd, 'tmp', 'm2-local')
|
149
|
-
|
150
|
-
'lein update-in : assoc :local-repo "\"' + m2_repo + '\"" --'
|
151
|
-
end
|
152
|
-
|
153
|
-
# Prepares a staging directory for the specified project.
|
154
|
-
#
|
155
|
-
# @api private
|
156
|
-
def ezbake_stage
|
157
|
-
# Install the PuppetDB jar into the local repository
|
158
|
-
ezbake_local_cmd "#{ezbake_lein_prefix} install",
|
159
|
-
:throw_on_failure => true
|
160
|
-
|
161
|
-
# Run ezbake stage
|
162
|
-
ezbake_local_cmd "#{ezbake_lein_prefix} with-profile ezbake ezbake stage",
|
163
|
-
:throw_on_failure => true
|
164
|
-
|
165
|
-
# Boostrap packaging, and grab configuration info from project
|
166
|
-
staging_dir = File.join('target','staging')
|
167
|
-
Dir.chdir(staging_dir) do
|
168
|
-
ezbake_local_cmd 'rake package:bootstrap'
|
169
|
-
|
170
|
-
load 'ezbake.rb'
|
171
|
-
ezbake = EZBake::Config
|
172
|
-
ezbake[:package_version] = `printf $(rake pl:print_build_param[ref] | tail -n 1)`
|
173
|
-
EZBakeUtils.config = ezbake
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
# Executes a local command using system, logging the prepared command
|
178
|
-
#
|
179
|
-
# @param [String] cmd command to execute
|
180
|
-
# @param [Hash] opts options
|
181
|
-
# @option opts [bool] :throw_on_failure If true, throws an
|
182
|
-
# exception if the exit code is non-zero. Defaults to false.
|
183
|
-
# @return [bool] true if exit == 0 false if otherwise
|
184
|
-
# @raise [RuntimeError] if :throw_on_failure is true and
|
185
|
-
# command fails
|
186
|
-
# @api private
|
187
|
-
def ezbake_local_cmd cmd, opts={}
|
188
|
-
opts = {
|
189
|
-
:throw_on_failure => false,
|
190
|
-
}.merge(opts)
|
191
|
-
|
192
|
-
logger.notify "localhost $ #{cmd}"
|
193
|
-
result = system cmd
|
194
|
-
if opts[:throw_on_failure] && result == false
|
195
|
-
raise RuntimeError, "Command failure #{cmd}"
|
196
|
-
end
|
197
|
-
result
|
198
|
-
end
|
199
|
-
|
200
|
-
# Retrieve the tarball installation name. This is the name of
|
201
|
-
# the tarball without the .tar.gz extension, and the name of the
|
202
|
-
# path where it will unpack to.
|
203
|
-
#
|
204
|
-
# @return [String] name of the tarball and directory
|
205
|
-
# @api private
|
206
|
-
def ezbake_install_name
|
207
|
-
ezbake = ezbake_config
|
208
|
-
project_package_version = ezbake[:package_version]
|
209
|
-
project_name = ezbake[:project]
|
210
|
-
"%s-%s" % [ project_name, project_package_version ]
|
211
|
-
end
|
212
|
-
|
213
|
-
# Returns the full path to the installed software on the remote host.
|
214
|
-
#
|
215
|
-
# This only returns the path, it doesn't work out if its installed or
|
216
|
-
# not.
|
217
|
-
#
|
218
|
-
# @return [String] path to the installation dir
|
219
|
-
# @api private
|
220
|
-
def ezbake_install_dir
|
221
|
-
"/root/#{ezbake_install_name}"
|
222
|
-
end
|
223
|
-
|
224
|
-
# A helper that wraps the execution of install.sh in the proper
|
225
|
-
# ezbake installation directory.
|
226
|
-
#
|
227
|
-
# @param [Host] host Host to run install.sh on
|
228
|
-
# @param [String] task Task to execute with install.sh
|
229
|
-
# @api private
|
230
|
-
def ezbake_installsh host, task=""
|
231
|
-
on host, "cd #{ezbake_install_dir}; bash install.sh #{task}"
|
232
|
-
end
|
233
|
-
|
234
|
-
# Only clone from given git URI if there is no existing git clone at the
|
235
|
-
# given local_path location.
|
236
|
-
#
|
237
|
-
# @param [String] upstream_uri git URI
|
238
|
-
# @param [String] local_path path to conditionally install to
|
239
|
-
# @param [String] branch to checkout
|
240
|
-
# @api private
|
241
|
-
def conditionally_clone upstream_uri, local_path, branch="origin/HEAD"
|
242
|
-
if ezbake_local_cmd "git --work-tree=#{local_path} --git-dir=#{local_path}/.git status"
|
243
|
-
ezbake_local_cmd "git --work-tree=#{local_path} --git-dir=#{local_path}/.git fetch origin"
|
244
|
-
ezbake_local_cmd "git --work-tree=#{local_path} --git-dir=#{local_path}/.git checkout #{branch}"
|
245
|
-
else
|
246
|
-
parent_dir = File.dirname(local_path)
|
247
|
-
FileUtils.mkdir_p(parent_dir)
|
248
|
-
ezbake_local_cmd "git clone #{upstream_uri} #{local_path}"
|
249
|
-
ezbake_local_cmd "git --work-tree=#{local_path} --git-dir=#{local_path}/.git checkout #{branch}"
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|
@@ -1,211 +0,0 @@
|
|
1
|
-
module Beaker
|
2
|
-
module DSL
|
3
|
-
module InstallUtils
|
4
|
-
#
|
5
|
-
# This module contains default values for FOSS puppet paths and directorys per-platform
|
6
|
-
#
|
7
|
-
module FOSSDefaults
|
8
|
-
|
9
|
-
#Here be the default download URLs
|
10
|
-
FOSS_DEFAULT_DOWNLOAD_URLS = {
|
11
|
-
:win_download_url => "http://downloads.puppetlabs.com/windows",
|
12
|
-
:mac_download_url => "http://downloads.puppetlabs.com/mac",
|
13
|
-
:pe_promoted_builds_url => "http://pm.puppetlabs.com",
|
14
|
-
:release_apt_repo_url => "http://apt.puppetlabs.com",
|
15
|
-
:release_yum_repo_url => "http://yum.puppetlabs.com",
|
16
|
-
:dev_builds_url => "http://builds.delivery.puppetlabs.net",
|
17
|
-
}
|
18
|
-
|
19
|
-
#Here be the pathing and default values for FOSS installs
|
20
|
-
#
|
21
|
-
FOSS_DEFAULTS = {
|
22
|
-
'freebsd' => {
|
23
|
-
'puppetserver-confdir' => '/etc/puppetserver/conf.d',
|
24
|
-
'puppetservice' => 'puppetmaster',
|
25
|
-
'puppetpath' => '/usr/local/etc/puppet/modules',
|
26
|
-
'puppetvardir' => '/var/lib/puppet',
|
27
|
-
'puppetbin' => '/usr/bin/puppet',
|
28
|
-
'puppetbindir' => '/usr/bin',
|
29
|
-
'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
|
30
|
-
'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
|
31
|
-
'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
|
32
|
-
'hieradatadir' => '/usr/local/etc/puppet/modules/hieradata',
|
33
|
-
'hieraconf' => '/usr/local/etc/puppet/modules/hiera.yaml',
|
34
|
-
'distmoduledir' => '/usr/local/etc/puppet/modules',
|
35
|
-
'sitemoduledir' => '/usr/share/puppet/modules',
|
36
|
-
},
|
37
|
-
'openbsd' => {
|
38
|
-
'puppetserver-confdir' => '/etc/puppetserver/conf.d',
|
39
|
-
'puppetservice' => 'puppetmaster',
|
40
|
-
'puppetpath' => '/etc/puppet/modules',
|
41
|
-
'puppetvardir' => '/var/puppet',
|
42
|
-
'puppetbin' => '/usr/local/bin/puppet',
|
43
|
-
'puppetbindir' => '/usr/local/bin',
|
44
|
-
'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
|
45
|
-
'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
|
46
|
-
'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
|
47
|
-
'hieradatadir' => '/etc/puppet/hieradata',
|
48
|
-
'hieraconf' => '/etc/puppet/hiera.yaml',
|
49
|
-
'distmoduledir' => '/etc/puppet/modules',
|
50
|
-
'sitemoduledir' => '/usr/local/share/puppet/modules',
|
51
|
-
},
|
52
|
-
'mac' => {
|
53
|
-
'puppetserver-confdir' => '/etc/puppetserver/conf.d',
|
54
|
-
'puppetservice' => 'puppetmaster',
|
55
|
-
'puppetpath' => '/etc/puppet',
|
56
|
-
'puppetconfdir' => '/etc/puppet',
|
57
|
-
'puppetcodedir' => '/etc/puppet',
|
58
|
-
'puppetvardir' => '/var/lib/puppet',
|
59
|
-
'puppetbin' => '/usr/bin/puppet',
|
60
|
-
'puppetbindir' => '/usr/bin',
|
61
|
-
'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
|
62
|
-
'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
|
63
|
-
'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
|
64
|
-
'hieradatadir' => '/etc/puppet/hieradata',
|
65
|
-
'hieraconf' => '/etc/puppet/hiera.yaml',
|
66
|
-
'distmoduledir' => '/etc/puppet/modules',
|
67
|
-
'sitemoduledir' => '/usr/share/puppet/modules',
|
68
|
-
},
|
69
|
-
'unix' => {
|
70
|
-
'puppetserver-confdir' => '/etc/puppetserver/conf.d',
|
71
|
-
'puppetservice' => 'puppetmaster',
|
72
|
-
'puppetpath' => '/etc/puppet',
|
73
|
-
'puppetconfdir' => '/etc/puppet',
|
74
|
-
'puppetvardir' => '/var/lib/puppet',
|
75
|
-
'puppetbin' => '/usr/bin/puppet',
|
76
|
-
'puppetbindir' => '/usr/bin',
|
77
|
-
'privatebindir' => '/usr/bin',
|
78
|
-
'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
|
79
|
-
'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
|
80
|
-
'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
|
81
|
-
'hieradatadir' => '/etc/puppet/hieradata',
|
82
|
-
'hieraconf' => '/etc/puppet/hiera.yaml',
|
83
|
-
'distmoduledir' => '/etc/puppet/modules',
|
84
|
-
'sitemoduledir' => '/usr/share/puppet/modules',
|
85
|
-
},
|
86
|
-
'archlinux' => {
|
87
|
-
'puppetserver-confdir' => '/etc/puppetserver/conf.d',
|
88
|
-
'puppetservice' => 'puppetmaster',
|
89
|
-
'puppetpath' => '/etc/puppetlabs/puppet',
|
90
|
-
'puppetconfdir' => '/etc/puppetlabs/puppet',
|
91
|
-
'puppetvardir' => '/opt/puppetlabs/puppet/cache',
|
92
|
-
'puppetbin' => '/usr/bin/puppet',
|
93
|
-
'puppetbindir' => '/usr/bin',
|
94
|
-
'privatebindir' => '/usr/bin',
|
95
|
-
'hieralibdir' => '/var/lib/hiera',
|
96
|
-
'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
|
97
|
-
'hierabindir' => '/usr/bin',
|
98
|
-
'hieradatadir' => '/etc/puppetlabs/code/hiera',
|
99
|
-
'hieraconf' => '/etc/hiera.yaml',
|
100
|
-
'distmoduledir' => '/etc/puppetlabs/code/modules',
|
101
|
-
'sitemoduledir' => '/usr/share/puppet/modules',
|
102
|
-
},
|
103
|
-
'windows' => { #cygwin windows
|
104
|
-
'puppetpath' => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
|
105
|
-
'puppetconfdir' => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
|
106
|
-
'puppetcodedir' => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
|
107
|
-
'hieraconf' => '`cygpath -smF 35`/Puppetlabs/puppet/etc/hiera.yaml',
|
108
|
-
'puppetvardir' => '`cygpath -smF 35`/PuppetLabs/puppet/var',
|
109
|
-
'distmoduledir' => '`cygpath -smF 35`/PuppetLabs/puppet/etc/modules',
|
110
|
-
'sitemoduledir' => 'C:/usr/share/puppet/modules',
|
111
|
-
'hieralibdir' => '`cygpath -w /opt/puppet-git-repos/hiera/lib`',
|
112
|
-
'hierapuppetlibdir' => '`cygpath -w /opt/puppet-git-repos/hiera-puppet/lib`',
|
113
|
-
#let's just add both potential bin dirs to the path
|
114
|
-
'puppetbindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet/bin',
|
115
|
-
'privatebindir' => '/usr/bin',
|
116
|
-
'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
|
117
|
-
},
|
118
|
-
'pswindows' => { #windows windows
|
119
|
-
'distmoduledir' => 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules',
|
120
|
-
'sitemoduledir' => 'C:\\usr\\share\\puppet\\modules',
|
121
|
-
'hieralibdir' => 'C:\\opt\\puppet-git-repos\\hiera\\lib',
|
122
|
-
'hierapuppetlibdir' => 'C:\\opt\\puppet-git-repos\\hiera-puppet\\lib',
|
123
|
-
'hierabindir' => 'C:\\opt\\puppet-git-repos\\hiera\\bin',
|
124
|
-
'puppetpath' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\etc";"C:\\Program Files\\Puppet Labs\\Puppet\\etc"',
|
125
|
-
'hieraconf' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\etc\\hiera.yaml";"C:\\Program Files\\Puppet Labs\\Puppet\\etc\\hiera.yaml"',
|
126
|
-
'puppetvardir' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\var";"C:\\Program Files\\Puppet Labs\\Puppet\\var"',
|
127
|
-
'puppetbindir' => '"C:\\Program Files (x86)\\Puppet Labs\\Puppet\\bin";"C:\\Program Files\\Puppet Labs\\Puppet\\bin"',
|
128
|
-
},
|
129
|
-
}
|
130
|
-
|
131
|
-
|
132
|
-
# Add the appropriate foss defaults to the host object so that they can be accessed using host[option], set host[:type] = foss
|
133
|
-
# @param [Host] host A single host to act upon
|
134
|
-
# @param [String] platform The platform type of this host, one of windows, pswindows, freebsd, mac & unix
|
135
|
-
def add_platform_foss_defaults(host, platform)
|
136
|
-
FOSS_DEFAULTS[platform].each_pair do |key, val|
|
137
|
-
host[key] = val
|
138
|
-
end
|
139
|
-
# add the group and type for backwards compatability
|
140
|
-
if host['platform'] =~ /windows/
|
141
|
-
host['group'] = 'Administrators'
|
142
|
-
else
|
143
|
-
host['group'] = 'puppet'
|
144
|
-
end
|
145
|
-
host['type'] = 'foss'
|
146
|
-
end
|
147
|
-
|
148
|
-
# Add the appropriate foss defaults to an array of hosts
|
149
|
-
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
150
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
151
|
-
def add_foss_defaults_on(hosts)
|
152
|
-
block_on hosts do | host |
|
153
|
-
case host.class.to_s.downcase
|
154
|
-
when /aix|unix/
|
155
|
-
platform = 'unix'
|
156
|
-
when /freebsd/
|
157
|
-
platform = 'freebsd'
|
158
|
-
when /openbsd/
|
159
|
-
platform = 'openbsd'
|
160
|
-
when /mac/
|
161
|
-
platform = 'mac'
|
162
|
-
when /pswindows/
|
163
|
-
platform = 'pswindows'
|
164
|
-
when /archlinux/
|
165
|
-
platform = 'archlinux'
|
166
|
-
else
|
167
|
-
platform = 'windows'
|
168
|
-
end
|
169
|
-
add_platform_foss_defaults(host, platform)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
# Remove the appropriate foss defaults from the host object so that they can no longer be accessed using host[option], set host[:type] = nil
|
174
|
-
# @param [Host] host A single host to act upon
|
175
|
-
# @param [String] platform The platform type of this host, one of windows, pswindows, freebsd, mac & unix
|
176
|
-
def remove_platform_foss_defaults(host, platform)
|
177
|
-
FOSS_DEFAULTS[platform].each_pair do |key, val|
|
178
|
-
host.delete(key)
|
179
|
-
end
|
180
|
-
host['group'] = nil
|
181
|
-
host['type'] = nil
|
182
|
-
end
|
183
|
-
|
184
|
-
# Remove the appropriate foss defaults from an array of hosts
|
185
|
-
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
186
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
187
|
-
def remove_foss_defaults_on(hosts)
|
188
|
-
block_on hosts do | host |
|
189
|
-
case host.class.to_s.downcase
|
190
|
-
when /aix|unix/
|
191
|
-
platform = 'unix'
|
192
|
-
when /freebsd/
|
193
|
-
platform = 'freebsd'
|
194
|
-
when /openbsd/
|
195
|
-
platform = 'openbsd'
|
196
|
-
when /mac/
|
197
|
-
platform = 'mac'
|
198
|
-
when /pswindows/
|
199
|
-
platform = 'pswindows'
|
200
|
-
else
|
201
|
-
platform = 'windows'
|
202
|
-
end
|
203
|
-
remove_platform_foss_defaults(host, platform)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|