lib/kafo/puppet_module_parser.rb in kafo-0.3.12 vs lib/kafo/puppet_module_parser.rb in kafo-0.3.13
- old
+ new
@@ -22,13 +22,17 @@
end
def initialize(file)
@file = file
raise ModuleName, "File not found #{file}, check you answer file" unless File.exists?(file)
- parser = Puppet::Parser::Parser.new('production')
- values = Puppet.settings.instance_variable_get('@values')
- values[:production][:confdir] ||= '/' # just some stubbing
+ Puppet.settings[:confdir] ||= '/' # just some stubbing
+ if Puppet::Node::Environment.respond_to?(:create)
+ env = Puppet::Node::Environment.create(:production, [], '')
+ else
+ env = Puppet::Node::Environment.new(:production)
+ end
+ parser = Puppet::Parser::Parser.new(env)
parser.import(@file)
# Find object corresponding to class defined in init.pp in list of hostclasses
parser.environment.known_resource_types.hostclasses.each do |ast_objects|
ast_type = ast_objects.last
@@ -37,9 +41,10 @@
# Find object in list of definitions
parser.environment.known_resource_types.definitions.each do |ast_objects|
ast_type = ast_objects.last
@object = ast_type.last if ast_type.last.file == file
end
+ parser
end
# TODO - store parsed object type (Puppet::Parser::AST::Variable must be dumped later)
def values
parameters = {}