beaker-task_helper 1.8.0 → 1.9.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 +8 -0
- data/CHANGELOG.md +8 -1
- data/README.md +1 -0
- data/beaker-task_helper.gemspec +1 -1
- data/lib/beaker-task_helper.rb +47 -18
- data/lib/beaker-task_helper/inventory.rb +27 -13
- data/lib/beaker-task_helper/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bcf5930a20707c66d650da88128840336b2a410d695cf725a03324d4c15383b
|
4
|
+
data.tar.gz: 938bfb0ac2ad710fe28be83a5ef7e0a2321e5830bfe8147b2fbf3ee119da4d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 708f25c7c19660a84ca4bcfb96f02b6fb4c731d6835efdcc9684cee581ad7eb7e6dc10e2206caa35bf000b445ffa8dd02251581a1c66d83201db8441d5f19752
|
7
|
+
data.tar.gz: 60798664cf9d835a1045299f1064021a523d9ac46e149ca8605a836f7286748a6d42ccddae2002461feec7486c6a1c0fc8ef88ad25b25f4274a0d098632d46d7
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
# Change Log
|
2
|
+
|
3
|
+
### 1.9.0
|
4
|
+
### Added
|
5
|
+
- Added `BEAKER_BOLT_VERSION` environment variable to set the version of Bolt used to generate an inventory file.
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
- Updated the helper to query the version of Bolt installed on the Beaker host when generating an inventory file.
|
9
|
+
|
2
10
|
### 1.8.0
|
3
11
|
### Changed
|
4
12
|
- Updated the helper to be compatible with [Bolt 2.0 changes](https://github.com/puppetlabs/bolt/blob/master/CHANGELOG.md). *Bolt 2.0 introduced some [backwards-incompatible changes](https://github.com/puppetlabs/bolt/blob/master/CHANGELOG.md#bolt-200-2020-02-19) that you should be aware of before upgrading to this version.*
|
@@ -9,7 +17,6 @@
|
|
9
17
|
- Puppet 6 collection handling fix
|
10
18
|
- PE `puppet access login` fixes
|
11
19
|
|
12
|
-
|
13
20
|
## 1.7.0
|
14
21
|
### Added
|
15
22
|
- (maint) - Work around for [BOLT-845](https://tickets.puppetlabs.com/browse/BOLT-845), installing ffi on el5 machines).
|
data/README.md
CHANGED
data/beaker-task_helper.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_development_dependency 'rubocop'
|
24
|
-
spec.add_development_dependency 'rake', '~>
|
24
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
25
25
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
26
|
spec.add_development_dependency 'beaker', '>= 3.0.0'
|
27
27
|
spec.add_development_dependency 'beaker-rspec'
|
data/lib/beaker-task_helper.rb
CHANGED
@@ -8,6 +8,40 @@ module Beaker::TaskHelper # rubocop:disable Style/ClassAndModuleChildren
|
|
8
8
|
(on default, puppet('--version')).output.chomp
|
9
9
|
end
|
10
10
|
|
11
|
+
def bolt_path
|
12
|
+
if fact_on(default, 'osfamily') == 'windows'
|
13
|
+
if ENV['BEAKER_PUPPET_COLLECTION'].nil? || %w[pc1 puppet5 puppet6].include?(ENV['BEAKER_PUPPET_COLLECTION'])
|
14
|
+
'/cygdrive/c/Program\ Files/Puppet\ Labs/Puppet/sys/ruby/bin/bolt.bat'
|
15
|
+
else
|
16
|
+
'/cygdrive/c/Program\ Files/Puppet\ Labs/Puppet/puppet/bin/bolt.bat'
|
17
|
+
end
|
18
|
+
else
|
19
|
+
# If bolt was installed as a package
|
20
|
+
if File.exist?('/opt/puppetlabs/puppet/bin/bolt')
|
21
|
+
'/opt/puppetlabs/puppet/bin/bolt'
|
22
|
+
else
|
23
|
+
# Or as a gem
|
24
|
+
'bolt'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the version of Bolt installed on the beakerhost. Used to determine
|
30
|
+
# which inventory file version to generate.
|
31
|
+
#
|
32
|
+
def self.bolt_version(beakerhost = nil)
|
33
|
+
return ENV['BEAKER_BOLT_VERSION'] if ENV['BEAKER_BOLT_VERSION']
|
34
|
+
|
35
|
+
beakerhost ||= default
|
36
|
+
begin
|
37
|
+
on(beakerhost, "#{bolt_path} --version")
|
38
|
+
rescue Beaker::Host::CommandFailure
|
39
|
+
# If bolt isn't installed, default to 1.18.0 which is the latest version
|
40
|
+
# to support only v1 inventory
|
41
|
+
'1.18.0'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
11
45
|
DEFAULT_PASSWORD = if ENV.has_key?('BEAKER_password')
|
12
46
|
ENV['BEAKER_password']
|
13
47
|
elsif !defined?(default)
|
@@ -18,14 +52,15 @@ module Beaker::TaskHelper # rubocop:disable Style/ClassAndModuleChildren
|
|
18
52
|
'root'
|
19
53
|
end
|
20
54
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
55
|
+
DEFAULT_BOLT_VERSION = if ENV['BEAKER_PUPPET_COLLECTION'].nil? || ENV['BEAKER_PUPPET_COLLECTION'] == 'pc1'
|
56
|
+
# puppet4 uses an older version of ruby (2.1.9) that bolt has stopped supporting
|
57
|
+
'0.16.1'.freeze
|
58
|
+
else
|
59
|
+
# CODEREVIEW: Can we update this to 1.x?
|
60
|
+
'0.23.0'.freeze
|
61
|
+
end
|
27
62
|
|
28
|
-
def install_bolt_on(hosts, version =
|
63
|
+
def install_bolt_on(hosts, version = DEFAULT_BOLT_VERSION, source = nil)
|
29
64
|
unless default[:docker_image_commands].nil?
|
30
65
|
if default[:docker_image_commands].to_s.include? 'yum'
|
31
66
|
on(hosts, 'yum install -y make gcc ruby-devel', acceptable_exit_codes: [0, 1]).stdout
|
@@ -64,8 +99,8 @@ INSTALL_BOLT_PP
|
|
64
99
|
ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i
|
65
100
|
end
|
66
101
|
|
67
|
-
def target_flag
|
68
|
-
if version_is_less('1.18.0',
|
102
|
+
def target_flag(host=default)
|
103
|
+
if version_is_less('1.18.0', self.bolt_version(host))
|
69
104
|
'--targets'
|
70
105
|
else
|
71
106
|
'--nodes'
|
@@ -125,23 +160,17 @@ INSTALL_BOLT_PP
|
|
125
160
|
def run_bolt_task(task_name:, params: nil, password: DEFAULT_PASSWORD,
|
126
161
|
host: '127.0.0.1', format: 'human', module_path: nil)
|
127
162
|
if fact_on(default, 'osfamily') == 'windows'
|
128
|
-
bolt_path = if ENV['BEAKER_PUPPET_COLLECTION'].nil? || ENV['BEAKER_PUPPET_COLLECTION'] == 'pc1' || ENV['BEAKER_PUPPET_COLLECTION'] == 'puppet5' || ENV['BEAKER_PUPPET_COLLECTION'] == 'puppet6'
|
129
|
-
'/cygdrive/c/Program\ Files/Puppet\ Labs/Puppet/sys/ruby/bin/bolt.bat'
|
130
|
-
else
|
131
|
-
'/cygdrive/c/Program\ Files/Puppet\ Labs/Puppet/puppet/bin/bolt.bat'
|
132
|
-
end
|
133
163
|
module_path ||= 'C:/ProgramData/PuppetLabs/code/modules'
|
134
164
|
|
135
|
-
if version_is_less('0.15.0',
|
165
|
+
if version_is_less('0.15.0', self.bolt_version)
|
136
166
|
check = '--no-ssl'
|
137
167
|
else
|
138
168
|
check = '--insecure'
|
139
169
|
end
|
140
170
|
else
|
141
|
-
bolt_path = '/opt/puppetlabs/puppet/bin/bolt'
|
142
171
|
module_path ||='/etc/puppetlabs/code/modules'
|
143
172
|
|
144
|
-
if version_is_less('0.15.0',
|
173
|
+
if version_is_less('0.15.0', self.bolt_version)
|
145
174
|
check = '--no-host-key-check'
|
146
175
|
else
|
147
176
|
check = '--insecure'
|
@@ -165,7 +194,7 @@ INSTALL_BOLT_PP
|
|
165
194
|
end
|
166
195
|
|
167
196
|
def run_puppet_task(task_name:, params: nil, host: '127.0.0.1', format: 'human')
|
168
|
-
args = ['task', 'run', task_name, target_flag, host]
|
197
|
+
args = ['task', 'run', task_name, target_flag(master), host]
|
169
198
|
if params.class == Hash
|
170
199
|
args << '--params'
|
171
200
|
args << params.to_json
|
@@ -1,16 +1,25 @@
|
|
1
1
|
require 'beaker'
|
2
|
+
require 'beaker-task_helper'
|
2
3
|
|
3
4
|
module Beaker
|
4
5
|
module TaskHelper
|
5
6
|
module Inventory
|
6
|
-
def
|
7
|
-
if version_is_less('1.18.0',
|
8
|
-
|
7
|
+
def inventory_version
|
8
|
+
if version_is_less('1.18.0', Beaker::TaskHelper.bolt_version)
|
9
|
+
2
|
9
10
|
else
|
10
|
-
|
11
|
+
1
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
15
|
+
def target_key
|
16
|
+
inventory_version == 2 ? 'targets' : 'nodes'
|
17
|
+
end
|
18
|
+
|
19
|
+
def uri_key
|
20
|
+
inventory_version == 2 ? 'uri' : 'name'
|
21
|
+
end
|
22
|
+
|
14
23
|
# This attempts to make a bolt inventory hash from beakers hosts
|
15
24
|
# roles should be targetable by bolt as groups
|
16
25
|
def hosts_to_inventory
|
@@ -41,9 +50,12 @@ module Beaker
|
|
41
50
|
else
|
42
51
|
config = { 'transport' => 'ssh',
|
43
52
|
'ssh' => { 'host-key-check' => false } }
|
44
|
-
%i[password user
|
53
|
+
%i[password user].each do |k|
|
45
54
|
config['ssh'][k.to_s] = host[:ssh][k] if host[:ssh][k]
|
46
55
|
end
|
56
|
+
if host[:ssh][:port]
|
57
|
+
config['ssh']['port'] = host[:ssh][:port].to_i
|
58
|
+
end
|
47
59
|
|
48
60
|
case host[:hypervisor]
|
49
61
|
when 'docker'
|
@@ -69,18 +81,20 @@ module Beaker
|
|
69
81
|
end
|
70
82
|
|
71
83
|
{
|
72
|
-
|
84
|
+
uri_key => node_name,
|
73
85
|
'config' => config
|
74
86
|
}
|
75
87
|
end
|
76
88
|
|
77
|
-
{ target_key => nodes,
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
89
|
+
inv = { target_key => nodes,
|
90
|
+
'groups' => groups,
|
91
|
+
'config' => {
|
92
|
+
'ssh' => {
|
93
|
+
'host-key-check' => false
|
94
|
+
}
|
95
|
+
} }
|
96
|
+
inv.merge!({'version' => 2}) if inventory_version == 2
|
97
|
+
inv
|
84
98
|
end
|
85
99
|
end
|
86
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker-task_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,6 +101,7 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
+
- ".github/dependabot.yml"
|
104
105
|
- ".gitignore"
|
105
106
|
- ".rspec"
|
106
107
|
- ".rubocop.yml"
|
@@ -136,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
137
|
- !ruby/object:Gem::Version
|
137
138
|
version: '0'
|
138
139
|
requirements: []
|
139
|
-
rubygems_version: 3.0.
|
140
|
+
rubygems_version: 3.0.8
|
140
141
|
signing_key:
|
141
142
|
specification_version: 4
|
142
143
|
summary: Ruby gem to help testing tasks with Beaker
|