diff options
Diffstat (limited to 'lib/puppet/provider')
-rw-r--r-- | lib/puppet/provider/ini_setting/ruby.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/puppet/provider/ini_setting/ruby.rb b/lib/puppet/provider/ini_setting/ruby.rb index 2c13847..af7a073 100644 --- a/lib/puppet/provider/ini_setting/ruby.rb +++ b/lib/puppet/provider/ini_setting/ruby.rb @@ -2,6 +2,28 @@ require File.expand_path('../../../util/ini_file', __FILE__) Puppet::Type.type(:ini_setting).provide(:ruby) do + def self.instances + if self.respond_to?(:file_path) + # figure out what to do about the seperator + ini_file = Puppet::Util::IniFile.new(file_path, '=') + resources = [] + ini_file.section_names.each do |section_name| + ini_file.get_settings(section_name).each do |setting, value| + resources.push( + new( + :name => "#{section_name}/#{setting}", + :value => value, + :ensure => :present + ) + ) + end + end + resources + else + raise(Puppet::Error, 'Ini_settings only support collecting instances when a file path is hard coded') + end + end + def exists? ini_file.get_value(section, setting) end @@ -36,7 +58,11 @@ Puppet::Type.type(:ini_setting).provide(:ruby) do end def file_path - resource[:path] + if self.class.respond_to?(:file_path) + self.class.file_path + else + resource[:path] + end end def separator |