beaker-task_helper 1.4.5 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/beaker-task_helper/inventory.rb +79 -0
- data/lib/beaker-task_helper/version.rb +1 -1
- data/lib/beaker-task_helper.rb +4 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5461a9dd5bbdf5db33df7a7bf126f9d991d0c652
|
4
|
+
data.tar.gz: f6eb73f923362c1aa16a744e16785a0f60efa9e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94468e40179836abdf014e7c46c285b30412c3c8d26d0ef1b3f6174f6f41d671a26a463b34a494208c2e1dd196435c2e52cbc35858cbb217d8fbc88bee262938
|
7
|
+
data.tar.gz: fe3366b11a9d5b8009c1b7a3d53717ffe16ba9c2a24a5b91835b1799cc090b33765f730bdcb6e38d383b8089a19144bbf6ea0d931c2ca4362bb0ced48f352b1d
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'beaker'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
module TaskHelper
|
5
|
+
module Inventory
|
6
|
+
# This attempts to make a bolt inventory hash from beakers hosts
|
7
|
+
# roles should be targetable by bolt as groups
|
8
|
+
def hosts_to_inventory
|
9
|
+
groups = []
|
10
|
+
|
11
|
+
def add_node(node, group_name, groups)
|
12
|
+
if group_name =~ %r{\A[a-z0-9_]+\Z}
|
13
|
+
group = groups.find { |g| g['name'] == group_name }
|
14
|
+
unless group
|
15
|
+
group = { 'name' => group_name, 'nodes' => [] }
|
16
|
+
groups << group
|
17
|
+
end
|
18
|
+
group['nodes'] << node
|
19
|
+
else
|
20
|
+
puts "invalid group name #{group_name} skipping"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
nodes = hosts.map do |host|
|
25
|
+
# Make sure nodes with IPs have unique target names
|
26
|
+
node_name = host[:ip] ? "#{host[:ip]}?n=#{host.hostname}" : host.hostname
|
27
|
+
|
28
|
+
if host[:platform] =~ %r{windows}
|
29
|
+
config = { 'transport' => 'winrm',
|
30
|
+
'winrm' => { 'ssl' => false,
|
31
|
+
'user' => host[:user],
|
32
|
+
'password' => ENV['BEAKER_password'] } }
|
33
|
+
else
|
34
|
+
config = { 'transport' => 'ssh',
|
35
|
+
'ssh' => { 'host-key-check' => false } }
|
36
|
+
%i[password user port].each do |k|
|
37
|
+
config['ssh'][k.to_s] = host[:ssh][k] if host[:ssh][k]
|
38
|
+
end
|
39
|
+
|
40
|
+
case host[:hypervisor]
|
41
|
+
when 'docker'
|
42
|
+
nil
|
43
|
+
when 'vagrant'
|
44
|
+
key = nil
|
45
|
+
keys = host.connection.instance_variable_get(:@ssh).options[:keys]
|
46
|
+
key = keys.first if keys
|
47
|
+
config['ssh']['private-key'] = key if key
|
48
|
+
when 'vmpooler'
|
49
|
+
key = nil
|
50
|
+
keys = host[:ssh][:keys]
|
51
|
+
key = keys.first if keys
|
52
|
+
config['ssh']['private-key'] = key if key
|
53
|
+
else
|
54
|
+
raise "Can't generate inventory for platform #{host[:platform]} hypervisor #{host[:hypervisor]}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# make alias groups for each role
|
59
|
+
host[:roles].each do |role|
|
60
|
+
add_node(node_name, role, groups)
|
61
|
+
end
|
62
|
+
|
63
|
+
{
|
64
|
+
'name' => node_name,
|
65
|
+
'config' => config
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
{ 'nodes' => nodes,
|
70
|
+
'groups' => groups,
|
71
|
+
'config' => {
|
72
|
+
'ssh' => {
|
73
|
+
'host-key-check' => false
|
74
|
+
}
|
75
|
+
} }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/beaker-task_helper.rb
CHANGED
@@ -38,6 +38,10 @@ INSTALL_BOLT_PP
|
|
38
38
|
pp << "source => '#{source}'" if source
|
39
39
|
pp << '}'
|
40
40
|
apply_manifest_on(host, pp)
|
41
|
+
|
42
|
+
bolt_confdir = "#{on(host, 'echo $HOME').stdout.chomp}/.puppetlabs/bolt"
|
43
|
+
on host, "mkdir -p #{bolt_confdir}"
|
44
|
+
create_remote_file(host, "#{bolt_confdir}/analytics.yaml", { 'disabled' => true }.to_yaml)
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
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.
|
4
|
+
version: 1.5.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-
|
11
|
+
date: 2018-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- appveyor.yml
|
115
115
|
- beaker-task_helper.gemspec
|
116
116
|
- lib/beaker-task_helper.rb
|
117
|
+
- lib/beaker-task_helper/inventory.rb
|
117
118
|
- lib/beaker-task_helper/version.rb
|
118
119
|
homepage: https://github.com/puppetlabs/beaker-task_helper
|
119
120
|
licenses:
|
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
version: '0'
|
136
137
|
requirements: []
|
137
138
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.5.1
|
139
140
|
signing_key:
|
140
141
|
specification_version: 4
|
141
142
|
summary: Ruby gem to help testing tasks with Beaker
|