Commits

Etienne Perot committed 81dab25 Merge

Merge branch 'content-ini' into pupfiles

* content-ini:
Implement "content" parameter which allows specifying ini data inline. Allows templates to be used.

  • Participants
  • Parent commits 3894e2b, c79d55d
  • Branches pupfiles

Comments (0)

Files changed (2)

File lib/puppet/provider/ini_setting/ruby.rb

 Puppet::Type.type(:ini_setting).provide(:ruby) do
 
   def exists?
-    return true unless resource[:source].empty?
+    return true unless resource[:source].empty? and resource[:content].nil?
     ini_file.get_value(section, setting)
   end
 

File lib/puppet/type/ini_setting.rb

     end
   end
 
+  newparam(:content) do
+    desc 'ini-style string containing the sections/settings/values to apply to the target .ini file.'
+  end
+
   newparam(:key_val_separator) do
     desc 'The separator string to use between each setting name and value. ' +
         'Defaults to " = ", but you could use this to override e.g. whether ' +
   end
 
   def eval_generate
-    return [] if self[:source].empty?
+    return [] if self[:source].empty? and self[:content].nil?
     content = nil
-    self[:source].each do |source|
-      if tmp = Puppet::FileServing::Content.indirection.find(source, :environment => self.catalog.environment)
-        content = tmp.content
-        break
+    content = self[:content] unless self[:content].nil?
+    unless self[:source].empty?
+      self[:source].each do |source|
+        if tmp = Puppet::FileServing::Content.indirection.find(source, :environment => self.catalog.environment)
+          content = tmp.content
+          break
+        end
       end
+      fail 'Could not find any valid source URLs' unless content
     end
-    fail 'Could not find any valid source URLs' unless content
     source_ini = Puppet::Util::IniFile.new(content, self[:key_val_separator], false)
     children = []
     title = self[:name]
       source_ini.section_settings(section).each do |setting|
         options = @original_parameters.merge(
           :source  => [],
+          :content => nil,
           :section => section,
           :setting => setting,
           :value   => source_ini.get_value(section, setting),