beaker-task_helper 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/beaker/task_helper.rb +43 -19
- data/lib/beaker/task_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 260b636cab7f87c21df1ecf2cdcf861010d26846
|
4
|
+
data.tar.gz: cd13935358710badae2c8eaf27b2bd590e9cf658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 779ce2f9bde38892dfecdf8868e6e920c231bf5dde2411959db6ada5a12138103c5b499a7d9ed80fb8d616e04bd3e59908ef77291be78cbb3a2d8639f55f2ba0
|
7
|
+
data.tar.gz: f431c134a371d38e7442d501fefaa8d3358f5601645d2586f8ba059abf5bcca2de6edf27bf61abbf458303fee76c4c1a5059f8581b237a9e68b6b3b81dd5a31d
|
data/CHANGELOG.md
CHANGED
data/lib/beaker/task_helper.rb
CHANGED
@@ -9,25 +9,35 @@ module Beaker::TaskHelper # rubocop:disable Style/ClassAndModuleChildren
|
|
9
9
|
end
|
10
10
|
|
11
11
|
DEFAULT_PASSWORD = if default[:hypervisor] == 'vagrant'
|
12
|
-
|
13
|
-
elsif default[:hypervisor] == 'vcloud'
|
12
|
+
'puppet'
|
13
|
+
elsif default[:hypervisor] == 'vcloud' || default[:hypervisor] == 'vmpooler'
|
14
14
|
'Qu@lity!'
|
15
15
|
else
|
16
16
|
'root'
|
17
17
|
end
|
18
18
|
|
19
|
-
BOLT_VERSION = '
|
19
|
+
BOLT_VERSION = '0.7.0'.freeze
|
20
20
|
|
21
|
-
def install_bolt_on(hosts, version = BOLT_VERSION)
|
21
|
+
def install_bolt_on(hosts, version = BOLT_VERSION, source = nil)
|
22
22
|
unless default[:docker_image_commands].nil?
|
23
|
-
if default[:docker_image_commands].to_s.include?
|
24
|
-
on(hosts,
|
25
|
-
elsif default[:docker_image_commands].to_s.include?
|
26
|
-
on(hosts,
|
23
|
+
if default[:docker_image_commands].to_s.include? 'yum'
|
24
|
+
on(hosts, 'yum install -y make gcc ruby-devel', acceptable_exit_codes: [0, 1]).stdout
|
25
|
+
elsif default[:docker_image_commands].to_s.include? 'apt-get'
|
26
|
+
on(hosts, 'apt-get install -y make gcc ruby-dev', acceptable_exit_codes: [0, 1]).stdout
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
|
+
Array(hosts).each do |host|
|
32
|
+
pp = <<-INSTALL_BOLT_PP
|
33
|
+
package { 'bolt' :
|
34
|
+
provider => 'puppet_gem',
|
35
|
+
ensure => '#{version}',
|
36
|
+
INSTALL_BOLT_PP
|
37
|
+
pp << "source => '#{source}'" if source
|
38
|
+
pp << '}'
|
39
|
+
apply_manifest_on(host, pp)
|
40
|
+
end
|
31
41
|
end
|
32
42
|
|
33
43
|
def pe_install?
|
@@ -39,11 +49,11 @@ module Beaker::TaskHelper # rubocop:disable Style/ClassAndModuleChildren
|
|
39
49
|
end
|
40
50
|
|
41
51
|
def run_task(task_name:, params: nil, password: DEFAULT_PASSWORD, format: 'human')
|
42
|
-
if pe_install?
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
52
|
+
output = if pe_install?
|
53
|
+
run_puppet_task(task_name: task_name, params: params)
|
54
|
+
else
|
55
|
+
run_bolt_task(task_name: task_name, params: params, password: password)
|
56
|
+
end
|
47
57
|
|
48
58
|
if format == 'json'
|
49
59
|
output = JSON.parse(output)
|
@@ -53,16 +63,30 @@ module Beaker::TaskHelper # rubocop:disable Style/ClassAndModuleChildren
|
|
53
63
|
end
|
54
64
|
end
|
55
65
|
|
56
|
-
def run_bolt_task(task_name:, params: nil, password: DEFAULT_PASSWORD, host:
|
57
|
-
if
|
58
|
-
|
66
|
+
def run_bolt_task(task_name:, params: nil, password: DEFAULT_PASSWORD, host: 'localhost', format: 'human') # rubocop:disable Metrics/LineLength, Lint/UnusedMethodArgument
|
67
|
+
if fact_on(default, 'osfamily') == 'windows'
|
68
|
+
bolt_path = '/cygdrive/c/Program\ Files/Puppet\ Labs/Puppet/sys/ruby/bin/bolt.bat'
|
69
|
+
module_path = 'C:/ProgramData/PuppetLabs/code/modules'
|
59
70
|
else
|
60
|
-
|
71
|
+
bolt_path = '/opt/puppetlabs/puppet/bin/bolt'
|
72
|
+
module_path = '/etc/puppetlabs/code/modules'
|
73
|
+
end
|
74
|
+
bolt_full_cli = "#{bolt_path} task run #{task_name} --insecure -m #{module_path} --nodes #{host} --password #{password}" # rubocop:disable Metrics/LineLength
|
75
|
+
bolt_full_cli << if params.class == Hash
|
76
|
+
" --params '#{params.to_json}'"
|
77
|
+
else
|
78
|
+
" #{params}"
|
79
|
+
end
|
80
|
+
# windows is special
|
81
|
+
if fact_on(default, 'osfamily') == 'windows'
|
82
|
+
bolt_full_cli << ' --transport winrm --user Administrator'
|
61
83
|
end
|
84
|
+
puts "BOLT_CLI: #{bolt_full_cli}" if ENV['BEAKER_debug']
|
85
|
+
on(default, bolt_full_cli, acceptable_exit_codes: [0, 1]).stdout
|
62
86
|
end
|
63
87
|
|
64
88
|
def run_puppet_task(task_name:, params: nil, host: 'localhost', format: 'human')
|
65
|
-
args = ['task', 'run', task_name, '--nodes', host
|
89
|
+
args = ['task', 'run', task_name, '--nodes', host]
|
66
90
|
if params.class == Hash
|
67
91
|
args << '--params'
|
68
92
|
args << params.to_json
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|