boltwash 0.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 +7 -0
- data/bolt.rb +160 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 57665589df84a1e04ea2dad5a2fecc31adda58d86d3b2b579ba9324e4e58af02
|
4
|
+
data.tar.gz: 8b42d2eb0e9fdc9ed9d0e0052253550e87cd8041d67ebe562573611f49f1f0a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dea6c8c3db7641f673fe5a6cfca2191b79499721fc6ddff80d4d1dd59c39f5c0b908f9910092984d2a459d08481062f40acaa0fa0f950fb0e18067e390fd3283
|
7
|
+
data.tar.gz: f75a41d46944efe6b48ec63374703ac847a85675bb6c14f69858cec4569973a9caebed88f6a30113b37f98b2471f8f4f2faba3b8664c5b1f2d192b0829a42e20
|
data/bolt.rb
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bolt/inventory'
|
5
|
+
require 'wash'
|
6
|
+
|
7
|
+
# For now we're going to mock out the plugin interface. It requires more setup
|
8
|
+
# to get PAL/PuppetDB working.
|
9
|
+
class Plugin
|
10
|
+
attr_accessor :plugin_hooks
|
11
|
+
def initialize
|
12
|
+
@plugin_hooks = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def reference?(_input)
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
def resolve_references(ref)
|
20
|
+
ref
|
21
|
+
end
|
22
|
+
|
23
|
+
def resolve_top_level_references(ref)
|
24
|
+
ref
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Boltwash < Wash::Entry
|
29
|
+
label 'bolt'
|
30
|
+
is_singleton
|
31
|
+
parent_of 'Group'
|
32
|
+
description <<~DESC
|
33
|
+
A plugin for Puppet Bolt's inventory. You can see target configuration in entry
|
34
|
+
metadata. You can SSH to targets and view their filesystems in 'fs' directories.
|
35
|
+
|
36
|
+
All groups are shown in this directory, with the special 'all' group including
|
37
|
+
all targets in the inventory.
|
38
|
+
DESC
|
39
|
+
|
40
|
+
def init(config)
|
41
|
+
boltdir = config[:dir] ? Bolt::Boltdir.new(config[:dir]) : Bolt::Boltdir.default_boltdir
|
42
|
+
bolt_config = Bolt::Config.from_boltdir(boltdir)
|
43
|
+
@inventory = Bolt::Inventory.from_config(bolt_config, Plugin.new)
|
44
|
+
prefetch :list
|
45
|
+
end
|
46
|
+
|
47
|
+
def list
|
48
|
+
groups = @inventory.group_names
|
49
|
+
groups.map { |group| Group.new(@inventory, group) }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class Group < Wash::Entry
|
54
|
+
label 'group'
|
55
|
+
parent_of 'Target'
|
56
|
+
description <<~DESC
|
57
|
+
This is a group. Listing it shows all targets in the group.
|
58
|
+
DESC
|
59
|
+
|
60
|
+
def initialize(inventory, name)
|
61
|
+
@inventory = inventory
|
62
|
+
@name = name
|
63
|
+
prefetch :list
|
64
|
+
end
|
65
|
+
|
66
|
+
def list
|
67
|
+
targets = @inventory.get_targets(@name)
|
68
|
+
targets.map { |target| Target.new(target) }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
class Target < Wash::Entry
|
74
|
+
label 'target'
|
75
|
+
parent_of VOLUMEFS
|
76
|
+
description <<~DESC
|
77
|
+
This is a target. You can view target configuration with the 'meta' command,
|
78
|
+
and SSH to the target if it accepts SSH connections. If SSH works, the 'fs'
|
79
|
+
directory will show its filesystem.
|
80
|
+
DESC
|
81
|
+
partial_metadata_schema begin
|
82
|
+
# Provides a merge of v1 and v2 target schemas. This makes it possible to match
|
83
|
+
# either while still providing useful information to Wash.
|
84
|
+
{
|
85
|
+
type: 'object',
|
86
|
+
properties: {
|
87
|
+
name: { type: 'string' },
|
88
|
+
alias: {
|
89
|
+
type: 'array'
|
90
|
+
},
|
91
|
+
uri: { type: 'string' },
|
92
|
+
config: {
|
93
|
+
type: 'object',
|
94
|
+
properties: {
|
95
|
+
transport: { type: 'string' },
|
96
|
+
ssh: { type: 'object' },
|
97
|
+
winrm: { type: 'object' },
|
98
|
+
pcp: { type: 'object' },
|
99
|
+
local: { type: 'object' },
|
100
|
+
docker: { type: 'object' },
|
101
|
+
remote: { type: 'object' }
|
102
|
+
}
|
103
|
+
},
|
104
|
+
vars: {
|
105
|
+
type: 'object'
|
106
|
+
},
|
107
|
+
features: {
|
108
|
+
type: 'array'
|
109
|
+
},
|
110
|
+
facts: {
|
111
|
+
type: 'object'
|
112
|
+
},
|
113
|
+
plugin_hooks: {
|
114
|
+
type: 'object'
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
def known_hosts(host_key_check)
|
121
|
+
return nil unless host_key_check == false
|
122
|
+
|
123
|
+
# Disable host key checking by redirecting known hosts to an empty file
|
124
|
+
# This is future-proofing for when Wash works on Windows.
|
125
|
+
Gem.win_platform? ? 'NUL' : '/dev/null'
|
126
|
+
end
|
127
|
+
|
128
|
+
def transport_options(target)
|
129
|
+
{
|
130
|
+
host: target.host,
|
131
|
+
port: target.port,
|
132
|
+
user: target.user,
|
133
|
+
password: target.password,
|
134
|
+
identity_file: target.options['private-key'],
|
135
|
+
known_hosts: known_hosts(target.options['host-key-check'])
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
def initialize(target)
|
140
|
+
# Save just the target information we need as state.
|
141
|
+
@name = target.name
|
142
|
+
@partial_metadata = target.detail
|
143
|
+
# TODO: add WinRM
|
144
|
+
transport :ssh, transport_options(target) if target.protocol == 'ssh'
|
145
|
+
prefetch :list
|
146
|
+
end
|
147
|
+
|
148
|
+
def exec(*_args)
|
149
|
+
raise 'non-ssh protocols are not yet implemented'
|
150
|
+
end
|
151
|
+
|
152
|
+
def list
|
153
|
+
[volumefs('fs', maxdepth: 2)]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
Wash.enable_entry_schemas
|
158
|
+
Wash.prefetch_entry_schemas
|
159
|
+
Wash.pretty_print
|
160
|
+
Wash.run(Boltwash, ARGV)
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: boltwash
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Puppet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-01-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bolt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.47'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.47'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: wash
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.4'
|
41
|
+
description: A Wash plugin for examining Bolt inventory
|
42
|
+
email:
|
43
|
+
- puppet@puppet.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- bolt.rb
|
49
|
+
homepage: https://github.com/puppetlabs/boltwash
|
50
|
+
licenses:
|
51
|
+
- Apache-2.0
|
52
|
+
metadata: {}
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.3'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubygems_version: 3.0.3
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: A Wash plugin for Bolt inventory
|
72
|
+
test_files: []
|