Module: Motoko::Utils::PuppetDB
- Defined in:
- lib/motoko/utils/puppet_db.rb
Class Method Summary collapse
Class Method Details
.class_filter(klass) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/motoko/utils/puppet_db.rb', line 6 def self.class_filter(klass) operator = '=' if klass =~ %r{\A/.*/\z} klass = klass[1..-2] operator = '~' end "certname in resources[certname] { type = 'Class' and title #{operator} '#{klass.split('::').map(&:capitalize).join('::')}' }" end |
.fact_filter(fact) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/motoko/utils/puppet_db.rb', line 17 def self.fact_filter(fact) name, operator, value = fact.split(/([!<>]?=|[<>])/, 2) if operator == '=' && value =~ %r{\A/.*/\z} value = value[1..-2] operator = '~' end begin value = case value when 'true' then true when 'false' then false else Integer(value) end rescue ArgumentError value = "'#{value}'" end "certname in inventory[certname] { facts.#{name} #{operator} #{value} }" end |
.identity_filter(identity) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/motoko/utils/puppet_db.rb', line 38 def self.identity_filter(identity) operator = '=' if identity =~ %r{\A/.*/\z} identity = identity[1..-2] operator = '~' end "certname #{operator} '#{identity}'" end |