beaker-task_helper 1.3.0 → 1.4.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
  SHA1:
3
- metadata.gz: 2b67d20327e15bba80fc705279d00a66a5238326
4
- data.tar.gz: 886bb5ec8d0c12b921f7957aedd285222c814b47
3
+ metadata.gz: 4aa5e71c49d4a2414c546b7253e9ad625b03cb4b
4
+ data.tar.gz: 24db4ac16d07dd157b07832c48c5e3f274b2977c
5
5
  SHA512:
6
- metadata.gz: 00d3d517e0805475cbb87f734d523856281a740f588c6ef58b96ffd14c4b4b6068cc882e91ef820901ca134082ffb279e5081a3430438f11c8d5ffbb96baabff
7
- data.tar.gz: 163cae5d0dc532e61af406560867ae805e32cb0950739655851c3d32a6c6d1a768c5becb6d072682276c1784abbdab682eae9e733a900f18aafbf47825d0226a
6
+ metadata.gz: e2e75f30b9defb8407b9dfde6fd5a5c20c57a9d36086adc97754924713aaa61c2995b31f5e4ddec40ea1145121828d3972ffd6b545bfeb42b621146a681d06b3
7
+ data.tar.gz: cb41ff126ae70ae7b7c9b3c60dab8367ed5ad8ed37f5c5aaa25fb1e7e54470d1e0e63a1de1eb93a2337f9bbc3c93c1aeb8f3824494e3f12ee2c33e62a02683c6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ### 1.4.0
4
+
5
+ * Added `BEAKER_password` variable for remote tasks.
6
+ * Fix windows on bolt >=0.16.0
7
+ * Fix json output format.
8
+
3
9
  ### 1.3.0
4
10
 
5
11
  * Cleaning up the README
data/README.md CHANGED
@@ -1 +1,3 @@
1
1
  beaker-task_helper
2
+
3
+ Accepts Bolt password via the `BEAKER_password` environment variable.
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module TaskHelper
3
- VERSION = '1.3.0'.freeze
3
+ VERSION = '1.4.0'.freeze
4
4
  end
5
5
  end
@@ -8,10 +8,10 @@ module Beaker::TaskHelper # rubocop:disable Style/ClassAndModuleChildren
8
8
  (on default, puppet('--version')).output.chomp
9
9
  end
10
10
 
11
- DEFAULT_PASSWORD = if default[:hypervisor] == 'vagrant'
11
+ DEFAULT_PASSWORD = if ENV.has_key?('BEAKER_password')
12
+ ENV['BEAKER_password']
13
+ elsif default[:hypervisor] == 'vagrant'
12
14
  'puppet'
13
- elsif default[:hypervisor] == 'vcloud' || default[:hypervisor] == 'vmpooler'
14
- 'Qu@lity!'
15
15
  else
16
16
  'root'
17
17
  end
@@ -25,7 +25,6 @@ module Beaker::TaskHelper # rubocop:disable Style/ClassAndModuleChildren
25
25
  elsif default[:docker_image_commands].to_s.include? 'apt-get'
26
26
  on(hosts, 'apt-get install -y make gcc ruby-dev', acceptable_exit_codes: [0, 1]).stdout
27
27
  end
28
-
29
28
  end
30
29
 
31
30
  Array(hosts).each do |host|
@@ -51,10 +50,11 @@ INSTALL_BOLT_PP
51
50
  def run_task(task_name:, params: nil, password: DEFAULT_PASSWORD, host: nil, format: 'human')
52
51
  output = if pe_install?
53
52
  host = master.hostname if host.nil?
54
- run_puppet_task(task_name: task_name, params: params, host: host)
53
+ run_puppet_task(task_name: task_name, params: params, host: host, format: format)
55
54
  else
56
55
  host = 'localhost' if host.nil?
57
- run_bolt_task(task_name: task_name, params: params, password: password, host: host)
56
+ run_bolt_task(task_name: task_name, params: params,
57
+ password: password, host: host, format: format)
58
58
  end
59
59
 
60
60
  if format == 'json'
@@ -65,22 +65,31 @@ INSTALL_BOLT_PP
65
65
  end
66
66
  end
67
67
 
68
- def run_bolt_task(task_name:, params: nil, password: DEFAULT_PASSWORD, host: 'localhost', format: 'human') # rubocop:disable Metrics/LineLength, Lint/UnusedMethodArgument
68
+ def run_bolt_task(task_name:, params: nil, password: DEFAULT_PASSWORD,
69
+ host: 'localhost', format: 'human')
69
70
  if fact_on(default, 'osfamily') == 'windows'
70
71
  bolt_path = '/cygdrive/c/Program\ Files/Puppet\ Labs/Puppet/sys/ruby/bin/bolt.bat'
71
72
  module_path = 'C:/ProgramData/PuppetLabs/code/modules'
73
+
74
+ if Puppet::Util::Package.versioncmp(BOLT_VERSION, '0.15.0') > 0
75
+ check = '--no-ssl'
76
+ else
77
+ check = '--insecure'
78
+ end
72
79
  else
73
80
  bolt_path = '/opt/puppetlabs/puppet/bin/bolt'
74
81
  module_path = '/etc/puppetlabs/code/modules'
75
- end
76
82
 
77
- if Puppet::Util::Package.versioncmp(BOLT_VERSION, '0.15.0') > 0
78
- check = '--no-host-key-check'
79
- else
80
- check = '--insecure'
83
+ if Puppet::Util::Package.versioncmp(BOLT_VERSION, '0.15.0') > 0
84
+ check = '--no-host-key-check'
85
+ else
86
+ check = '--insecure'
87
+ end
81
88
  end
82
89
 
83
- bolt_full_cli = "#{bolt_path} task run #{task_name} #{check} -m #{module_path} --nodes #{host} --password #{password}" # rubocop:disable Metrics/LineLength
90
+ bolt_full_cli = "#{bolt_path} task run #{task_name} #{check} -m #{module_path} " \
91
+ "--nodes #{host} --password #{password}"
92
+ bolt_full_cli << " --format #{format}" if format != 'human'
84
93
  bolt_full_cli << if params.class == Hash
85
94
  " --params '#{params.to_json}'"
86
95
  else
@@ -91,7 +100,7 @@ INSTALL_BOLT_PP
91
100
  bolt_full_cli << ' --transport winrm --user Administrator'
92
101
  end
93
102
  puts "BOLT_CLI: #{bolt_full_cli}" if ENV['BEAKER_debug']
94
- on(default, bolt_full_cli, acceptable_exit_codes: [0, 1]).stdout
103
+ on(default, bolt_full_cli, acceptable_exit_codes: [0, 1, 2]).stdout
95
104
  end
96
105
 
97
106
  def run_puppet_task(task_name:, params: nil, host: 'localhost', format: 'human')
@@ -102,9 +111,9 @@ INSTALL_BOLT_PP
102
111
  else
103
112
  args << params
104
113
  end
105
- if format == 'json'
114
+ if format != 'human'
106
115
  args << '--format'
107
- args << 'json'
116
+ args << format
108
117
  end
109
118
  on(master, puppet(*args), acceptable_exit_codes: [0, 1]).stdout
110
119
  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.3.0
4
+ version: 1.4.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-02-12 00:00:00.000000000 Z
11
+ date: 2018-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
- rubygems_version: 2.6.8
138
+ rubygems_version: 2.6.14
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Ruby gem to help testing tasks with Beaker