jerakia 0.1.5 → 0.3.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: ee600c1fbdad02112c0dc0eca8ec525fd3da14c6
4
- data.tar.gz: 0d6d09801dece2e26e213bf3d8c424f3a211c444
3
+ metadata.gz: cfa6b5b4e283d6a8eac75289da4e456cdf7b4365
4
+ data.tar.gz: fd106c3ac2c92d1e18ff1a598b12ccde5a67bc40
5
5
  SHA512:
6
- metadata.gz: 87d13fce2376b9ea5593e2b6a8bf2e1084045db6f8bfe9854060e2d53243a2cbc1ed46552240c5af5be64dcfbddc82a7087ef1bb0e65f74564bedfc96af21b0f
7
- data.tar.gz: d81bea981e0a7571ea1be73424608cadea44066459845eac0d78f7931bfedfed62926f8903bebec6444b03a4a4e5fbfe98c4991839af8469d046a59387bbec82
6
+ metadata.gz: 7083168d80c4d3d9927eaee085b43199847321911dd63fb1866c5e18ba88aaacce65eb947fe9264c29feb35769152afd3bc8a68bbf60a9450e277c0e5b214610
7
+ data.tar.gz: 51a5f837b4b4b948e5f70f43116be92dfca2fd016104275d2c7901cb1d71f78e3a6f49d19a94adb29ef315e022f6f707c7192894b9ddecd05bbf141505d8868f
data/bin/jerakia CHANGED
@@ -6,7 +6,7 @@ require 'optparse'
6
6
 
7
7
  options = {
8
8
  :policy => "default",
9
- :config => "/etc/jerakia/jerakia.yml",
9
+ :config => "/etc/jerakia/jerakia.yaml",
10
10
  :scope => nil,
11
11
  :key => nil,
12
12
  :merge => "array",
@@ -48,7 +48,7 @@ class Hiera
48
48
  request = Jerakia::Request.new(
49
49
  :key => key,
50
50
  :namespace => namespace,
51
- :policy => @policy,
51
+ :policy => metadata[:jerakia_policy] || @policy,
52
52
  :lookup_type => lookup_type,
53
53
  :merge => merge_type,
54
54
  :metadata => metadata,
data/lib/jerakia/cache.rb CHANGED
@@ -29,7 +29,8 @@ class Jerakia::Cache
29
29
  end
30
30
 
31
31
  def get(index)
32
- @@bucket[index][:content]
32
+ data = @@bucket[index][:content]
33
+ Marshal::load(Marshal.dump(data))
33
34
  end
34
35
 
35
36
  def bucket
@@ -4,7 +4,7 @@ class Jerakia::Config
4
4
  attr_reader :policydir
5
5
  attr_reader :server_url
6
6
 
7
- def initialize(config='/etc/jerakia/jerakia.yml')
7
+ def initialize(config='/etc/jerakia/jerakia.yaml')
8
8
  unless File.exists?(config)
9
9
  Jerakia.crit("Config file #{config} not found")
10
10
  end
@@ -0,0 +1,68 @@
1
+ require 'lookup_http'
2
+
3
+
4
+ class Jerakia::Datasource
5
+ module Http
6
+
7
+ def run
8
+ #
9
+ # Do the lookup
10
+
11
+ Jerakia.log.debug("Searching key #{lookup.request.key} using the http datasource (#{whoami})")
12
+
13
+
14
+ option :host, { :type => String, :mandatory => true }
15
+ option :port, { :type => Integer, :default => 80 }
16
+ option :output, { :type => String, :default => 'json' }
17
+ option :failure, { :type => String, :default => 'graceful' }
18
+ option :ignore_404, { :default => true }
19
+ option :headers, { :type => Hash }
20
+ option :http_read_timeout, { :type => Integer }
21
+ option :use_ssl
22
+ option :ssl_ca_cert, { :type => String }
23
+ option :ssl_cert, { :type => String }
24
+ option :ssl_key, { :type => String }
25
+ option :ssl_verify
26
+ option :use_auth
27
+ option :auth_user, { :type => String }
28
+ option :auth_pass, { :type => String }
29
+ option :http_connect_timeout,{ :type => Integer }
30
+ option :paths, { :type => Array, :mandatory => true }
31
+
32
+
33
+ lookup_supported_params = [
34
+ :host,
35
+ :port,
36
+ :output,
37
+ :failure,
38
+ :ignore_404,
39
+ :headers,
40
+ :http_connect_timeout,
41
+ :http_read_timeout,
42
+ :use_ssl,
43
+ :ssl_ca_cert,
44
+ :ssl_cert,
45
+ :ssl_key,
46
+ :ssl_verify,
47
+ :use_auth,
48
+ :auth_user,
49
+ :auth_pass,
50
+ ]
51
+ lookup_params = options.select { |p| lookup_supported_params.include?(p) }
52
+ http_lookup = LookupHttp.new(lookup_params)
53
+
54
+ options[:paths].flatten.each do |path|
55
+ Jerakia.log.debug("Attempting to load data from #{path}")
56
+ return unless response.want?
57
+ data=http_lookup.get_parsed(path)
58
+ Jerakia.log.debug("Datasource provided #{data} looking for key #{lookup.request.key}")
59
+ if data[lookup.request.key]
60
+ Jerakia.log.debug("Found data #{data[lookup.request.key]}")
61
+ response.submit data[lookup.request.key]
62
+ end
63
+ end
64
+
65
+ end
66
+ end
67
+ end
68
+
@@ -1,6 +1,6 @@
1
1
  # This plugin reformats the lookup key according to a puppet's
2
- # Hiera system, so instead of looking up <key> in <path>/<namespace>.yml
3
- # we lookup <namespace>::<key> in <path>.yml
2
+ # Hiera system, so instead of looking up <key> in <path>/<namespace>.yaml
3
+ # we lookup <namespace>::<key> in <path>.yaml
4
4
  #
5
5
  # This is a useful plugin for people wanting to test drive Jerakia
6
6
  # but maintain an existing hiera filesystem layout and naming convention
data/lib/jerakia.rb CHANGED
@@ -14,7 +14,7 @@ class Jerakia
14
14
 
15
15
 
16
16
  def initialize(options={})
17
- configfile = options[:config] || '/etc/jerakia/jerakia.yml'
17
+ configfile = options[:config] || '/etc/jerakia/jerakia.yaml'
18
18
  @@config = Jerakia::Config.new(configfile)
19
19
 
20
20
  if @@config[:plugindir]
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jerakia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.3.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: 2015-09-10 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2015-10-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lookup_http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
13
27
  description: Extendable and flexible data lookup system
14
28
  email:
15
29
  executables:
@@ -30,7 +44,7 @@ files:
30
44
  - lib/jerakia/datasource/dummy.rb
31
45
  - lib/jerakia/datasource/file.rb
32
46
  - lib/jerakia/datasource/file/yaml.rb
33
- - lib/jerakia/foobar
47
+ - lib/jerakia/datasource/http.rb
34
48
  - lib/jerakia/launcher.rb
35
49
  - lib/jerakia/log.rb
36
50
  - lib/jerakia/lookup.rb
data/lib/jerakia/foobar DELETED
File without changes