lib/web-puppet.rb in web-puppet-0.1.1 vs lib/web-puppet.rb in web-puppet-0.2.0

- old
+ new

@@ -4,24 +4,32 @@ require 'json' require 'parseconfig' module WebPuppet class App - def call env + def initialize(filters=[]) + @filters = filters + end + + def call env Puppet[:config] = "/etc/puppet/puppet.conf" Puppet.parse_config - Puppet[:clientyamldir] = "$yamldir" + Puppet[:clientyamldir] = Puppet[:yamldir] Puppet::Node.indirection.terminus_class = :yaml nodes = Puppet::Node.indirection.search("*") data = {} nodes.each do |n| facts = Puppet::Node::Facts.indirection.find(n.name) tags = Puppet::Resource::Catalog.indirection.find(n.name).tags + @filters.each do |filter| + facts.values.delete(filter.strip) + end + data[n.name] = { :facts => facts.values, :tags => tags } end @@ -42,16 +50,22 @@ application.realm = 'Web Puppet' application end def self.run!(options) - application = self.new + conf = options[:config] ? ParseConfig.new(options[:config]) : false + + if conf && conf.get_value('filters') + application = self.new(conf.get_value('filters').split(',')) + else + application = self.new + end + daemonize = options[:daemonize] port = options[:port] - if options[:config] - conf = ParseConfig.new(options[:config]) + if conf application = application.add_auth(conf) if conf.get_value('password') daemonize = conf.get_value('daemonize') ? conf.get_value('daemonize') == "true" : daemonize port = conf.get_value('port') ? conf.get_value('port') : port end