jerakia-puppet 0.3.2 → 0.4.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/lib/hiera/backend/jerakia_backend.rb +59 -0
- data/lib/puppet/indirector/data_binding/jerakia.rb +33 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 808661bd140bd6e474a0f451679be544deaeb8a0
|
4
|
+
data.tar.gz: e9e4964ca4dc376798937d4e0889b83af14fca4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94afd61a8f7204e55bb8a26137a76855bcc86467d4eb5d40f235dc58628cff28373559e00818d3025c3ab564c3cc6427bf7cdee850b38e90b5fd6f9f1c971e7f
|
7
|
+
data.tar.gz: ac8a44f2be76eb880b300b36df11996066fe1d8b1d9c7e64eb8e873b05b4376e1010f07d7ea0e0d55cf12da1d7f0788fcfeaf824a71d859681aa929f0b27e828
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'puppet'
|
2
|
+
require 'puppet/resource'
|
3
|
+
|
4
|
+
class Hiera
|
5
|
+
module Backend
|
6
|
+
class Jerakia_backend
|
7
|
+
def initialize(config = nil)
|
8
|
+
require 'jerakia'
|
9
|
+
@config = config || Hiera::Config[:jerakia] || {}
|
10
|
+
@policy = @config[:policy] || 'default'
|
11
|
+
@jerakia = ::Jerakia.new(@config)
|
12
|
+
Jerakia.log.debug("[hiera] hiera backend loaded with policy #{@policy}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def lookup(key, scope, _order_override, resolution_type)
|
16
|
+
lookup_type = :first
|
17
|
+
merge_type = :none
|
18
|
+
|
19
|
+
case resolution_type
|
20
|
+
when :array
|
21
|
+
lookup_type = :cascade
|
22
|
+
merge_type = :array
|
23
|
+
when :hash
|
24
|
+
lookup_type = :cascade
|
25
|
+
merge_type = :hash
|
26
|
+
end
|
27
|
+
|
28
|
+
namespace = []
|
29
|
+
|
30
|
+
if key.include?('::')
|
31
|
+
lookup_key = key.split('::')
|
32
|
+
key = lookup_key.pop
|
33
|
+
namespace = lookup_key
|
34
|
+
end
|
35
|
+
|
36
|
+
Jerakia.log.debug("[hiera] backend invoked for key #{key} using namespace #{namespace}")
|
37
|
+
|
38
|
+
metadata = {}
|
39
|
+
metadata = if scope.is_a?(Hash)
|
40
|
+
scope.reject { |_k, v| v.is_a?(Puppet::Resource) }
|
41
|
+
else
|
42
|
+
scope.real.to_hash.reject { |_k, v| v.is_a?(Puppet::Resource) }
|
43
|
+
end
|
44
|
+
|
45
|
+
request = Jerakia::Request.new(
|
46
|
+
:key => key,
|
47
|
+
:namespace => namespace,
|
48
|
+
:policy => metadata['jerakia_policy'] || @policy,
|
49
|
+
:lookup_type => lookup_type,
|
50
|
+
:merge => merge_type,
|
51
|
+
:metadata => metadata
|
52
|
+
)
|
53
|
+
|
54
|
+
answer = @jerakia.lookup(request)
|
55
|
+
answer.payload
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'puppet/indirector/code'
|
2
|
+
require 'jerakia'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class Puppet::DataBinding::Jerakia < Puppet::Indirector::Code
|
6
|
+
desc 'Data binding for Jerakia'
|
7
|
+
|
8
|
+
attr_reader :jerakia
|
9
|
+
attr_reader :policy
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
@jerakia = ::Jerakia.new
|
13
|
+
@default_policy = 'default'
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def find(request)
|
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
|
23
|
+
jacreq = Jerakia::Request.new(
|
24
|
+
:key => key,
|
25
|
+
:namespace => namespace,
|
26
|
+
:policy => policy,
|
27
|
+
:lookup_type => :first,
|
28
|
+
:metadata => metadata
|
29
|
+
)
|
30
|
+
answer = jerakia.lookup(jacreq)
|
31
|
+
answer.payload
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jerakia-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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: 2017-
|
11
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jerakia-client
|
@@ -24,14 +24,16 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: Puppet databinding and hiera 3.x backend for Jerakia Server using
|
28
|
-
Jerakia client libraries
|
27
|
+
description: Legacy Puppet databinding and hiera 3.x backend for Jerakia Server using
|
28
|
+
the Jerakia client libraries
|
29
29
|
email:
|
30
30
|
executables: []
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- lib/hiera/backend/jerakia_backend.rb
|
34
35
|
- lib/hiera/backend/jerakiaserver_backend.rb
|
36
|
+
- lib/puppet/indirector/data_binding/jerakia.rb
|
35
37
|
- lib/puppet/indirector/data_binding/jerakiaserver.rb
|
36
38
|
homepage: http://jerakia.io
|
37
39
|
licenses:
|