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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bde2b067d8b91239fecd8d0575bb0f1aead07bbecab43e0e94fe9a810540bb3
4
- data.tar.gz: d726f66dfaa8ba05c27f2984f0816ee9f4615b04ae043e006bc47b2963bdc293
3
+ metadata.gz: 7bcf5930a20707c66d650da88128840336b2a410d695cf725a03324d4c15383b
4
+ data.tar.gz: 938bfb0ac2ad710fe28be83a5ef7e0a2321e5830bfe8147b2fbf3ee119da4d6f
5
5
  SHA512:
6
- metadata.gz: 069c72b69f6d2aacdeaeb889b3582e2e1828498b76b5401fbb6622b95ed9cab4ae15ce07381c13c0613b242f880e593e7d98776e9c305b014df901e4a0e8accf
7
- data.tar.gz: 734f52539d22377301826cb19215ff0e5e1f1d816e4a9ea08d62ba9afe7f5c318657c6caa150eba1da467be9808f950c2483cf85ec5883d50a0514d8974f33dd
6
+ metadata.gz: 708f25c7c19660a84ca4bcfb96f02b6fb4c731d6835efdcc9684cee581ad7eb7e6dc10e2206caa35bf000b445ffa8dd02251581a1c66d83201db8441d5f19752
7
+ data.tar.gz: 60798664cf9d835a1045299f1064021a523d9ac46e149ca8605a836f7286748a6d42ccddae2002461feec7486c6a1c0fc8ef88ad25b25f4274a0d098632d46d7
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "13:00"
8
+ open-pull-requests-limit: 10
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
@@ -1,3 +1,4 @@
1
1
  beaker-task_helper
2
2
 
3
3
  Accepts Bolt password via the `BEAKER_password` environment variable.
4
+ Accepts Bolt version via the `BEAKER_BOLT_VERSION` environment variable.
@@ -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', '~> 10.0'
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'
@@ -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
- BOLT_VERSION = if ENV['BEAKER_PUPPET_COLLECTION'].nil? || ENV['BEAKER_PUPPET_COLLECTION'] == 'pc1'
22
- # puppet4 uses an older version of ruby (2.1.9) that bolt has stopped supporting
23
- '0.16.1'.freeze
24
- else
25
- '0.23.0'.freeze
26
- end
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 = BOLT_VERSION, source = nil)
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', BOLT_VERSION)
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', BOLT_VERSION)
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', BOLT_VERSION)
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 target_key
7
- if version_is_less('1.18.0', BOLT_VERSION)
8
- 'targets'
7
+ def inventory_version
8
+ if version_is_less('1.18.0', Beaker::TaskHelper.bolt_version)
9
+ 2
9
10
  else
10
- 'nodes'
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 port].each do |k|
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
- 'name' => node_name,
84
+ uri_key => node_name,
73
85
  'config' => config
74
86
  }
75
87
  end
76
88
 
77
- { target_key => nodes,
78
- 'groups' => groups,
79
- 'config' => {
80
- 'ssh' => {
81
- 'host-key-check' => false
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
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module TaskHelper
3
- VERSION = '1.8.0'.freeze
3
+ VERSION = '1.9.0'.freeze
4
4
  end
5
5
  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.8.0
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: 2020-04-16 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
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.6
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