beaker-task_helper 1.7.1 → 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
- SHA1:
3
- metadata.gz: f6d8f14889f34d8454b6b7c3edacb8ccd5fef898
4
- data.tar.gz: c5cb9326641991c2ba2c7802aa9d8e8275f0de37
2
+ SHA256:
3
+ metadata.gz: 7bcf5930a20707c66d650da88128840336b2a410d695cf725a03324d4c15383b
4
+ data.tar.gz: 938bfb0ac2ad710fe28be83a5ef7e0a2321e5830bfe8147b2fbf3ee119da4d6f
5
5
  SHA512:
6
- metadata.gz: 6e5001028885a733480e6b98b2afcccc5bea4dfec1aedd8415bc71642583f16f2ea5c0286cd1617e6486e9d619a780658f03d390da73149cee389aaed2681a56
7
- data.tar.gz: 58af4abbbf3eab20be6c31e43b96cefec8da0d67c14876490c689f1fee7705aebdb52253cfdd46df1c936ec5dd4f232f0a4acc67df740195af13bcac151f72de
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,22 @@
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
+
10
+ ### 1.8.0
11
+ ### Changed
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.*
13
+
14
+ ### 1.7.1-4
15
+ ### Fixed
16
+ - `.ssh` directory path on OSX 10.12/10.13/10.14 and Solaris 10
17
+ - Puppet 6 collection handling fix
18
+ - PE `puppet access login` fixes
19
+
2
20
  ## 1.7.0
3
21
  ### Added
4
22
  - (maint) - Work around for [BOLT-845](https://tickets.puppetlabs.com/browse/BOLT-845), installing ffi on el5 machines).
data/CODEOWNERS ADDED
@@ -0,0 +1,2 @@
1
+ # This repo is owned by the Installer team
2
+ * @puppetlabs/installer-and-management
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,7 +99,17 @@ INSTALL_BOLT_PP
64
99
  ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i
65
100
  end
66
101
 
102
+ def target_flag(host=default)
103
+ if version_is_less('1.18.0', self.bolt_version(host))
104
+ '--targets'
105
+ else
106
+ '--nodes'
107
+ end
108
+ end
109
+
67
110
  def run_puppet_access_login(user:, password: '~!@#$%^*-/ aZ', lifetime: '5y')
111
+ peconf_password = get_unwrapped_pe_conf_value("console_admin_password")
112
+ password = peconf_password if peconf_password != nil && peconf_password != ""
68
113
  on(master, puppet('access', 'login', '--username', user, '--lifetime', lifetime), stdin: password)
69
114
  end
70
115
 
@@ -83,7 +128,7 @@ INSTALL_BOLT_PP
83
128
  case node.platform
84
129
  when /solaris-10/
85
130
  ssh_dir_path = '/.ssh/'
86
- when /osx-1012/
131
+ when /osx-10\.1(2|3|4)/
87
132
  ssh_dir_path = '/var/root/.ssh/'
88
133
  else
89
134
  ssh_dir_path = '/root/.ssh'
@@ -115,23 +160,17 @@ INSTALL_BOLT_PP
115
160
  def run_bolt_task(task_name:, params: nil, password: DEFAULT_PASSWORD,
116
161
  host: '127.0.0.1', format: 'human', module_path: nil)
117
162
  if fact_on(default, 'osfamily') == 'windows'
118
- bolt_path = if ENV['BEAKER_PUPPET_COLLECTION'].nil? || ENV['BEAKER_PUPPET_COLLECTION'] == 'pc1' || ENV['BEAKER_PUPPET_COLLECTION'] == 'puppet5'
119
- '/cygdrive/c/Program\ Files/Puppet\ Labs/Puppet/sys/ruby/bin/bolt.bat'
120
- else
121
- '/cygdrive/c/Program\ Files/Puppet\ Labs/Puppet/puppet/bin/bolt.bat'
122
- end
123
163
  module_path ||= 'C:/ProgramData/PuppetLabs/code/modules'
124
164
 
125
- if version_is_less('0.15.0', BOLT_VERSION)
165
+ if version_is_less('0.15.0', self.bolt_version)
126
166
  check = '--no-ssl'
127
167
  else
128
168
  check = '--insecure'
129
169
  end
130
170
  else
131
- bolt_path = '/opt/puppetlabs/puppet/bin/bolt'
132
171
  module_path ||='/etc/puppetlabs/code/modules'
133
172
 
134
- if version_is_less('0.15.0', BOLT_VERSION)
173
+ if version_is_less('0.15.0', self.bolt_version)
135
174
  check = '--no-host-key-check'
136
175
  else
137
176
  check = '--insecure'
@@ -139,7 +178,7 @@ INSTALL_BOLT_PP
139
178
  end
140
179
 
141
180
  bolt_full_cli = "#{bolt_path} task run #{task_name} #{check} -m #{module_path} " \
142
- "--nodes #{host} --password #{password}"
181
+ "#{target_flag} #{host} --password #{password}"
143
182
  bolt_full_cli << " --format #{format}" if format != 'human'
144
183
  bolt_full_cli << if params.class == Hash
145
184
  " --params '#{params.to_json}'"
@@ -155,7 +194,7 @@ INSTALL_BOLT_PP
155
194
  end
156
195
 
157
196
  def run_puppet_task(task_name:, params: nil, host: '127.0.0.1', format: 'human')
158
- args = ['task', 'run', task_name, '--nodes', host]
197
+ args = ['task', 'run', task_name, target_flag(master), host]
159
198
  if params.class == Hash
160
199
  args << '--params'
161
200
  args << params.to_json
@@ -176,7 +215,7 @@ INSTALL_BOLT_PP
176
215
  end
177
216
 
178
217
  def task_summary_line(total_hosts: 1, success_hosts: 1)
179
- "Job completed. #{success_hosts}/#{total_hosts} nodes succeeded|Ran on #{total_hosts} node"
218
+ "Job completed. #{success_hosts}/#{total_hosts} targets succeeded|Ran on #{total_hosts} target"
180
219
  end
181
220
  end
182
221
 
@@ -1,8 +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
7
+ def inventory_version
8
+ if version_is_less('1.18.0', Beaker::TaskHelper.bolt_version)
9
+ 2
10
+ else
11
+ 1
12
+ end
13
+ end
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
+
6
23
  # This attempts to make a bolt inventory hash from beakers hosts
7
24
  # roles should be targetable by bolt as groups
8
25
  def hosts_to_inventory
@@ -12,10 +29,10 @@ module Beaker
12
29
  if group_name =~ %r{\A[a-z0-9_]+\Z}
13
30
  group = groups.find { |g| g['name'] == group_name }
14
31
  unless group
15
- group = { 'name' => group_name, 'nodes' => [] }
32
+ group = { 'name' => group_name, target_key => [] }
16
33
  groups << group
17
34
  end
18
- group['nodes'] << node
35
+ group[target_key] << node
19
36
  else
20
37
  puts "invalid group name #{group_name} skipping"
21
38
  end
@@ -33,9 +50,12 @@ module Beaker
33
50
  else
34
51
  config = { 'transport' => 'ssh',
35
52
  'ssh' => { 'host-key-check' => false } }
36
- %i[password user port].each do |k|
53
+ %i[password user].each do |k|
37
54
  config['ssh'][k.to_s] = host[:ssh][k] if host[:ssh][k]
38
55
  end
56
+ if host[:ssh][:port]
57
+ config['ssh']['port'] = host[:ssh][:port].to_i
58
+ end
39
59
 
40
60
  case host[:hypervisor]
41
61
  when 'docker'
@@ -61,18 +81,20 @@ module Beaker
61
81
  end
62
82
 
63
83
  {
64
- 'name' => node_name,
84
+ uri_key => node_name,
65
85
  'config' => config
66
86
  }
67
87
  end
68
88
 
69
- { 'nodes' => nodes,
70
- 'groups' => groups,
71
- 'config' => {
72
- 'ssh' => {
73
- 'host-key-check' => false
74
- }
75
- } }
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
76
98
  end
77
99
  end
78
100
  end
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module TaskHelper
3
- VERSION = '1.7.1'.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.7.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: 2018-09-24 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,11 +101,13 @@ 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"
107
108
  - ".travis.yml"
108
109
  - CHANGELOG.md
110
+ - CODEOWNERS
109
111
  - CONTRIBUTING.md
110
112
  - Gemfile
111
113
  - LICENSE.txt
@@ -135,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
137
  - !ruby/object:Gem::Version
136
138
  version: '0'
137
139
  requirements: []
138
- rubyforge_project:
139
- rubygems_version: 2.5.1
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