Class: Jerakia::Lookup

Inherits:
Object
  • Object
show all
Defined in:
lib/jerakia/plugins/lookup/hiera_compat.rb,
lib/jerakia/lookup.rb,
lib/jerakia/plugins/lookup/confine.rb

Overview

This plugin reformats the lookup key according to a puppet's Hiera system, so instead of looking up in /.yml we lookup :: in .yml

This is a useful plugin for people wanting to test drive Jerakia but maintain an existing hiera filesystem layout and naming convention within the source data.

Defined Under Namespace

Modules: Plugin

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, req, scope, &block) ⇒ Lookup

Returns a new instance of Lookup.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jerakia/lookup.rb', line 16

def initialize(name,req,scope,&block)
  
  @name=name
  @request=req
  @valid=true
  @scope_object=scope
  @output_filters=[]
  @proceed=true
  extend Jerakia::Lookup::Plugin
  instance_eval &block
  
end

Instance Attribute Details

#datasource(source, opts = {}) ⇒ Object (readonly)

Returns the value of attribute datasource.



8
9
10
# File 'lib/jerakia/lookup.rb', line 8

def datasource
  @datasource
end

#lookuptype ⇒ Object (readonly)

Returns the value of attribute lookuptype.



10
11
12
# File 'lib/jerakia/lookup.rb', line 10

def lookuptype
  @lookuptype
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/jerakia/lookup.rb', line 13

def name
  @name
end

#output_filters ⇒ Object (readonly)

Returns the value of attribute output_filters.



12
13
14
# File 'lib/jerakia/lookup.rb', line 12

def output_filters
  @output_filters
end

#proceed ⇒ Object (readonly)

Returns the value of attribute proceed.



14
15
16
# File 'lib/jerakia/lookup.rb', line 14

def proceed
  @proceed
end

#request ⇒ Object

Returns the value of attribute request.



7
8
9
# File 'lib/jerakia/lookup.rb', line 7

def request
  @request
end

#scope_object ⇒ Object (readonly)

Returns the value of attribute scope_object.



11
12
13
# File 'lib/jerakia/lookup.rb', line 11

def scope_object
  @scope_object
end

#valid ⇒ Object (readonly)

Returns the value of attribute valid.



9
10
11
# File 'lib/jerakia/lookup.rb', line 9

def valid
  @valid
end

Instance Method Details

#continue ⇒ Object

lookup function: continue Will cause Jerakia to continue to the next lookup in the policy which is the default behaviour



66
67
68
# File 'lib/jerakia/lookup.rb', line 66

def continue
  @proceed = true
end

#invalidate ⇒ Object

lookup function: invalidate Setting invalidate will mean this lookup will be skipped in the policy



73
74
75
# File 'lib/jerakia/lookup.rb', line 73

def invalidate
  @valid=false
end

#output_filter(name, opts = {}) ⇒ Object



42
43
44
# File 'lib/jerakia/lookup.rb', line 42

def output_filter(name,opts={})
  @output_filters << { :name => name, :opts => opts }
end

#proceed? ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/jerakia/lookup.rb', line 46

def proceed?
  @proceed
end

#run ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/jerakia/lookup.rb', line 81

def run
  @datasource.run
  response=@datasource.response
  @output_filters.each do |filter|
    response.filter! filter[:name], filter[:opts]
  end
  return response
end

#scope ⇒ Object

If set, Jerakia will pass each Jerakia::Response object to an output filter plugin



37
38
39
# File 'lib/jerakia/lookup.rb', line 37

def scope
  @scope_object.value
end

#stop ⇒ Object

lookup function: stop Enabling stop sets @proceed to false, which will cause Jerakia not to load any more lookups in the policy if this lookup is deemed as valid. If the lookup is invalidated than Jerakia will progress to the next lookup. This is useful in conjuction with the confine plugin where we want to segregate some lookups but not worry about excluding from later lookups



58
59
60
# File 'lib/jerakia/lookup.rb', line 58

def stop
  @proceed = false
end

#valid? ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/jerakia/lookup.rb', line 77

def valid?
  return @valid
end