From cbc90d38347f8ca61de2208b16ffc76f9fd5938c Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Tue, 2 Oct 2012 18:53:53 -0700 Subject: Make value a property This commit converts value to a property so that it can be managed and modified when a file already has a value set. It was previously treating the line creation state the same as the update case, which is not in alignment with Puppet's model. --- lib/puppet/provider/ini_setting/ruby.rb | 12 +++++++++++- lib/puppet/type/ini_setting.rb | 9 +++++---- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/ini_setting/ruby.rb b/lib/puppet/provider/ini_setting/ruby.rb index aca8ba2..946685e 100644 --- a/lib/puppet/provider/ini_setting/ruby.rb +++ b/lib/puppet/provider/ini_setting/ruby.rb @@ -1,8 +1,9 @@ require File.expand_path('../../../util/ini_file', __FILE__) Puppet::Type.type(:ini_setting).provide(:ruby) do + def exists? - ini_file.get_value(resource[:section], resource[:setting]) == resource[:value].to_s + ini_file.get_value(section, setting) end def create @@ -11,6 +12,15 @@ Puppet::Type.type(:ini_setting).provide(:ruby) do @ini_file = nil end + def value + ini_file.get_value(section, setting) + end + + def value=(value) + ini_file.set_value(section, setting, resource[:value]) + ini_file.save + end + def section resource[:section] end diff --git a/lib/puppet/type/ini_setting.rb b/lib/puppet/type/ini_setting.rb index 50b6b38..4506231 100644 --- a/lib/puppet/type/ini_setting.rb +++ b/lib/puppet/type/ini_setting.rb @@ -17,10 +17,6 @@ Puppet::Type.newtype(:ini_setting) do desc 'The name of the setting to be defined.' end - newparam(:value) do - desc 'The value of the setting to be defined.' - end - newparam(:path) do desc 'The ini file Puppet will ensure contains the specified setting.' validate do |value| @@ -43,4 +39,9 @@ Puppet::Type.newtype(:ini_setting) do end end + newproperty(:value) do + desc 'The value of the setting to be defined.' + end + + end -- cgit v1.2.3