beaker-task_helper 1.0.1 → 1.1.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: ef435a23400c79c3f83e6a8b80c07ecb6bf7cfc2
4
- data.tar.gz: 8522c85a07a568ee2a588a6be1b6a4bc3e46f265
3
+ metadata.gz: 260b636cab7f87c21df1ecf2cdcf861010d26846
4
+ data.tar.gz: cd13935358710badae2c8eaf27b2bd590e9cf658
5
5
  SHA512:
6
- metadata.gz: 5ac493e3f3bbcb21d1a0551f85e3a6a79ca9b03bb102c642d4ce5ce877d86104ffaf78f6ff425abd7ae01c38e808667f533e6bcd0e6db4d885cb21afdfc96633
7
- data.tar.gz: cc95dba9146fcf288e3821b666fb095cf0d87834cd6cf1fd309c6e7c71a45c2e8c92172602ac5fda8f736bcaa124fa6cadea5987a2b2fffda61ece511763f451
6
+ metadata.gz: 779ce2f9bde38892dfecdf8868e6e920c231bf5dde2411959db6ada5a12138103c5b499a7d9ed80fb8d616e04bd3e59908ef77291be78cbb3a2d8639f55f2ba0
7
+ data.tar.gz: f431c134a371d38e7442d501fefaa8d3358f5601645d2586f8ba059abf5bcca2de6edf27bf61abbf458303fee76c4c1a5059f8581b237a9e68b6b3b81dd5a31d
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ### 1.1.0
4
+
5
+ * Better windows support.
6
+ * Make source for gem an argument.
7
+
3
8
  ### 1.0.1
4
9
 
5
10
  * Fix license and point to the correct github URL.
@@ -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
- 'puppet'
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 = '>= 0.7.0'
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? "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
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
- on(hosts, "/opt/puppetlabs/puppet/bin/gem install --source http://rubygems.delivery.puppetlabs.net bolt -v '#{BOLT_VERSION}'", acceptable_exit_codes: [0, 1]).stdout
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
- output = run_puppet_task(task_name: task_name, params: params)
44
- else
45
- output = run_bolt_task(task_name: task_name, params: params, password: password)
46
- end
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: "localhost", format: 'human')
57
- if params.class == Hash
58
- on(default, "/opt/puppetlabs/puppet/bin/bolt task run #{task_name} --insecure -m /etc/puppetlabs/code/modules --nodes #{host} --password #{password} --params '#{params.to_json}'", acceptable_exit_codes: [0, 1]).stdout # rubocop:disable Metrics/LineLength
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
- on(default, "/opt/puppetlabs/puppet/bin/bolt task run #{task_name} --insecure -m /etc/puppetlabs/code/modules --nodes #{host} --password #{password} #{params}", acceptable_exit_codes: [0, 1]).stdout # rubocop:disable Metrics/LineLength
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
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module TaskHelper
3
- VERSION = '1.0.1'.freeze
3
+ VERSION = '1.1.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.0.1
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-08 00:00:00.000000000 Z
11
+ date: 2017-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop