jerakia 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hiera/backend/jerakia_backend.rb +13 -14
- data/lib/jerakia/answer.rb +28 -27
- data/lib/jerakia/cache/entry.rb +2 -6
- data/lib/jerakia/cache/file.rb +53 -23
- data/lib/jerakia/cache.rb +44 -11
- data/lib/jerakia/cli/lookup.rb +124 -0
- data/lib/jerakia/cli/server.rb +50 -0
- data/lib/jerakia/cli/token.rb +64 -0
- data/lib/jerakia/cli.rb +7 -117
- data/lib/jerakia/config.rb +5 -5
- data/lib/jerakia/datasource/dummy.rb +1 -6
- data/lib/jerakia/datasource/file/json.rb +1 -3
- data/lib/jerakia/datasource/file/yaml.rb +1 -3
- data/lib/jerakia/datasource/file.rb +21 -44
- data/lib/jerakia/datasource/http.rb +17 -23
- data/lib/jerakia/datasource.rb +37 -36
- data/lib/jerakia/dsl/lookup.rb +4 -6
- data/lib/jerakia/dsl/policy.rb +11 -12
- data/lib/jerakia/error.rb +0 -5
- data/lib/jerakia/launcher.rb +26 -30
- data/lib/jerakia/log.rb +21 -22
- data/lib/jerakia/lookup/plugin/hiera.rb +3 -4
- data/lib/jerakia/lookup/plugin.rb +5 -6
- data/lib/jerakia/lookup/plugin_config.rb +31 -0
- data/lib/jerakia/lookup/pluginfactory.rb +30 -36
- data/lib/jerakia/lookup.rb +31 -32
- data/lib/jerakia/policy.rb +60 -45
- data/lib/jerakia/request.rb +3 -2
- data/lib/jerakia/response/filter/encryption.rb +7 -12
- data/lib/jerakia/response/filter/strsub.rb +4 -9
- data/lib/jerakia/response/filter.rb +5 -5
- data/lib/jerakia/response.rb +7 -13
- data/lib/jerakia/schema.rb +23 -35
- data/lib/jerakia/scope/metadata.rb +0 -1
- data/lib/jerakia/scope/puppetdb.rb +38 -0
- data/lib/jerakia/scope/server.rb +60 -0
- data/lib/jerakia/scope/yaml.rb +3 -4
- data/lib/jerakia/scope.rb +0 -2
- data/lib/jerakia/server/auth/token.rb +35 -0
- data/lib/jerakia/server/auth.rb +72 -0
- data/lib/jerakia/server/rest.rb +140 -0
- data/lib/jerakia/server.rb +41 -0
- data/lib/jerakia/util.rb +6 -7
- data/lib/jerakia/version.rb +1 -3
- data/lib/jerakia.rb +58 -40
- data/lib/puppet/indirector/data_binding/jerakia.rb +9 -11
- data/lib/puppet/indirector/data_binding/jerakia_rest.rb +11 -13
- metadata +78 -11
data/lib/jerakia.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Class Jerakia
|
2
|
+
#
|
3
|
+
# Main Jerakia class
|
4
|
+
#
|
2
5
|
class Jerakia
|
3
6
|
require 'jerakia/policy'
|
4
7
|
require 'jerakia/lookup'
|
@@ -11,72 +14,87 @@ class Jerakia
|
|
11
14
|
require 'jerakia/version'
|
12
15
|
require 'jerakia/error'
|
13
16
|
|
17
|
+
attr_reader :options
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
class << self
|
20
|
+
attr_reader :config
|
21
|
+
attr_reader :log
|
22
|
+
end
|
19
23
|
|
24
|
+
@config = nil
|
25
|
+
@log = nil
|
20
26
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
27
|
+
def initialize(options = {})
|
28
|
+
@options = options
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
logfile = options[:logfile] || @@config["logfile"] || "/var/log/jerakia.log"
|
30
|
+
load_config
|
31
|
+
load_log_handler
|
28
32
|
|
29
|
-
|
30
|
-
|
33
|
+
if config[:plugindir]
|
34
|
+
$LOAD_PATH << config[:plugindir] unless $LOAD_PATH.include?(config[:plugindir])
|
35
|
+
end
|
31
36
|
|
37
|
+
log.debug('Jerakia initialized')
|
32
38
|
Jerakia.log.verbose("Jerakia started. Version #{Jerakia::VERSION}")
|
33
39
|
end
|
34
40
|
|
35
41
|
def lookup(request)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
42
|
+
lookup_instance = Jerakia::Launcher.new(request)
|
43
|
+
lookup_instance.invoke_from_file
|
44
|
+
lookup_instance.answer
|
45
|
+
rescue Jerakia::Error => e
|
46
|
+
Jerakia.fatal(e.message, e)
|
47
|
+
end
|
43
48
|
|
49
|
+
def self.fatal(msg, e)
|
50
|
+
stacktrace = e.backtrace.join("\n")
|
51
|
+
Jerakia.log.fatal msg
|
52
|
+
Jerakia.log.fatal "Full stacktrace output:\n#{$!}\n\n#{stacktrace}"
|
53
|
+
raise e
|
44
54
|
end
|
45
55
|
|
56
|
+
|
46
57
|
def config
|
47
|
-
|
58
|
+
self.class.config
|
48
59
|
end
|
49
60
|
|
50
|
-
def
|
51
|
-
|
52
|
-
Jerakia.log.fatal msg
|
53
|
-
Jerakia.log.fatal "Full stacktrace output:\n#{$!}\n\n#{stacktrace}"
|
54
|
-
raise e
|
61
|
+
def log
|
62
|
+
self.class.log
|
55
63
|
end
|
56
64
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
65
|
+
class << self
|
66
|
+
def config=(data)
|
67
|
+
@config ||= data
|
68
|
+
end
|
69
|
+
|
70
|
+
def log=(logger)
|
71
|
+
@log ||= logger
|
62
72
|
end
|
63
|
-
return @@filecache[name]
|
64
73
|
end
|
65
74
|
|
66
|
-
|
67
|
-
|
75
|
+
private
|
76
|
+
|
77
|
+
def configfile
|
78
|
+
options[:config] || ENV['JERAKIA_CONFIG'] || '/etc/jerakia/jerakia.yaml'
|
68
79
|
end
|
69
80
|
|
70
|
-
def
|
71
|
-
|
81
|
+
def config_instance
|
82
|
+
File.exist?(configfile) ? Jerakia::Config.load_from_file(configfile) : Jerakia::Config.new
|
72
83
|
end
|
73
84
|
|
74
|
-
def
|
75
|
-
|
85
|
+
def load_config
|
86
|
+
self.class.config = config_instance
|
76
87
|
end
|
77
88
|
|
78
|
-
def
|
79
|
-
|
89
|
+
def loglevel
|
90
|
+
options[:loglevel] || config['loglevel'] || 'info'
|
80
91
|
end
|
81
92
|
|
93
|
+
def logfile
|
94
|
+
options[:logfile] || config['logfile'] || '/var/log/jerakia.log'
|
95
|
+
end
|
96
|
+
|
97
|
+
def load_log_handler
|
98
|
+
self.class.log = Jerakia::Log.new(loglevel.to_sym, logfile)
|
99
|
+
end
|
82
100
|
end
|
@@ -3,33 +3,31 @@ require 'jerakia'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
class Puppet::DataBinding::Jerakia < Puppet::Indirector::Code
|
6
|
-
desc
|
6
|
+
desc 'Data binding for Jerakia'
|
7
7
|
|
8
8
|
attr_reader :jerakia
|
9
9
|
attr_reader :policy
|
10
10
|
|
11
11
|
def initialize(*args)
|
12
|
-
@jerakia
|
13
|
-
@default_policy =
|
12
|
+
@jerakia = ::Jerakia.new
|
13
|
+
@default_policy = 'default'
|
14
14
|
super
|
15
15
|
end
|
16
16
|
|
17
17
|
def find(request)
|
18
|
-
|
19
|
-
lookupdata
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
policy=metadata["jerakia_policy"] || @default_policy
|
18
|
+
lookupdata = request.key.split(/::/)
|
19
|
+
key = lookupdata.pop
|
20
|
+
namespace = lookupdata
|
21
|
+
metadata = request.options[:variables].to_hash.reject { |_k, v| v.is_a?(Puppet::Resource) }
|
22
|
+
policy = metadata['jerakia_policy'] || @default_policy
|
24
23
|
jacreq = Jerakia::Request.new(
|
25
24
|
:key => key,
|
26
25
|
:namespace => namespace,
|
27
26
|
:policy => policy,
|
28
27
|
:lookup_type => :first,
|
29
|
-
:metadata => metadata
|
28
|
+
:metadata => metadata
|
30
29
|
)
|
31
30
|
answer = jerakia.lookup(jacreq)
|
32
31
|
answer.payload
|
33
32
|
end
|
34
33
|
end
|
35
|
-
|
@@ -10,37 +10,35 @@ require 'jerakia'
|
|
10
10
|
require 'json'
|
11
11
|
|
12
12
|
class Puppet::DataBinding::Jerakia_rest < Puppet::Indirector::Code
|
13
|
-
desc
|
13
|
+
desc 'Data binding for Jerakia'
|
14
14
|
|
15
15
|
attr_reader :jerakia
|
16
16
|
attr_reader :jerakia_url
|
17
17
|
attr_reader :policy
|
18
18
|
|
19
19
|
def initialize(*args)
|
20
|
-
@jerakia
|
21
|
-
@jerakia_url
|
22
|
-
@policy =
|
20
|
+
@jerakia = ::Jerakia.new
|
21
|
+
@jerakia_url = @jerakia.config.server_url
|
22
|
+
@policy = 'puppet'
|
23
23
|
super
|
24
24
|
end
|
25
25
|
|
26
26
|
def find(request)
|
27
|
+
lookupdata = request.key.split(/::/)
|
28
|
+
key = lookupdata.pop
|
29
|
+
namespace = lookupdata
|
27
30
|
|
28
|
-
|
29
|
-
key=lookupdata.pop
|
30
|
-
namespace=lookupdata
|
31
|
+
# metadata = request.options[:variables].to_hash
|
31
32
|
|
32
|
-
#metadata = request.options[:variables].to_hash
|
33
|
-
|
34
33
|
metadata = {
|
35
|
-
:environment => request.options[:variables].environment
|
34
|
+
:environment => request.options[:variables].environment
|
36
35
|
}
|
37
|
-
payload={
|
36
|
+
payload = {
|
38
37
|
:namespace => namespace,
|
39
38
|
:lookup_type => :first,
|
40
|
-
:metadata => metadata
|
39
|
+
:metadata => metadata
|
41
40
|
}.to_json
|
42
41
|
response = RestClient.get "#{jerakia_url}/#{policy}/#{key}", :params => { :payload => payload }
|
43
42
|
response
|
44
43
|
end
|
45
44
|
end
|
46
|
-
|
metadata
CHANGED
@@ -1,57 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jerakia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Dunn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.19'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.19'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: deep_merge
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: lookup_http
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 1.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sinatra
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "<"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "<"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: data_mapper
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dm-sqlite-adapter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: thin
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.6'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.6'
|
55
111
|
description: Extendable and flexible data lookup system
|
56
112
|
email:
|
57
113
|
executables:
|
@@ -67,6 +123,9 @@ files:
|
|
67
123
|
- lib/jerakia/cache/entry.rb
|
68
124
|
- lib/jerakia/cache/file.rb
|
69
125
|
- lib/jerakia/cli.rb
|
126
|
+
- lib/jerakia/cli/lookup.rb
|
127
|
+
- lib/jerakia/cli/server.rb
|
128
|
+
- lib/jerakia/cli/token.rb
|
70
129
|
- lib/jerakia/config.rb
|
71
130
|
- lib/jerakia/datasource.rb
|
72
131
|
- lib/jerakia/datasource/dummy.rb
|
@@ -82,6 +141,7 @@ files:
|
|
82
141
|
- lib/jerakia/lookup.rb
|
83
142
|
- lib/jerakia/lookup/plugin.rb
|
84
143
|
- lib/jerakia/lookup/plugin/hiera.rb
|
144
|
+
- lib/jerakia/lookup/plugin_config.rb
|
85
145
|
- lib/jerakia/lookup/pluginfactory.rb
|
86
146
|
- lib/jerakia/policy.rb
|
87
147
|
- lib/jerakia/request.rb
|
@@ -92,7 +152,13 @@ files:
|
|
92
152
|
- lib/jerakia/schema.rb
|
93
153
|
- lib/jerakia/scope.rb
|
94
154
|
- lib/jerakia/scope/metadata.rb
|
155
|
+
- lib/jerakia/scope/puppetdb.rb
|
156
|
+
- lib/jerakia/scope/server.rb
|
95
157
|
- lib/jerakia/scope/yaml.rb
|
158
|
+
- lib/jerakia/server.rb
|
159
|
+
- lib/jerakia/server/auth.rb
|
160
|
+
- lib/jerakia/server/auth/token.rb
|
161
|
+
- lib/jerakia/server/rest.rb
|
96
162
|
- lib/jerakia/util.rb
|
97
163
|
- lib/jerakia/version.rb
|
98
164
|
- lib/puppet/indirector/data_binding/jerakia.rb
|
@@ -107,18 +173,19 @@ require_paths:
|
|
107
173
|
- lib
|
108
174
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
175
|
requirements:
|
110
|
-
- -
|
176
|
+
- - ">="
|
111
177
|
- !ruby/object:Gem::Version
|
112
178
|
version: '0'
|
113
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
180
|
requirements:
|
115
|
-
- -
|
181
|
+
- - ">="
|
116
182
|
- !ruby/object:Gem::Version
|
117
183
|
version: '0'
|
118
184
|
requirements: []
|
119
185
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.5.1
|
121
187
|
signing_key:
|
122
188
|
specification_version: 4
|
123
189
|
summary: Extendable and flexible ata lookup system
|
124
190
|
test_files: []
|
191
|
+
has_rdoc:
|