On Fri, Jan 30, 2015 at 7:29 AM, Luke Kanies <[email protected]> wrote:

> On Jan 30, 2015, at 1:37 AM, Nan Liu <[email protected]> wrote:
>
>
> I'm trying to use ini_setting as a parent provider. Everything works well,
> but to support purging, the resources provider need to specify the target
> file via self.file_path. Initially this seems straightforward, but the
> config file location can vary based on installation settings. All the
> examples I've seen have a hard coded filepath in self.file_path. I can't
> use parameter in the puppet type to provide the file path because it's only
> accessible in the normal setter/getter via resources[:file_path].
> scope.lookupvar is definitely not available, so is there a way to access
> the catalog in self.* methods in the provider?
>
>
> The self.* methods are class methods, so they shouldn’t generally have
> access to per-run values like the catalog.
>
> How are you setting the path for the file?  You could maybe have that
> process set the path variable on the provider.
>

So using puppetlabs-splunk as an example [1] (for more background see
inifile [2]). The provider hard codes the config file path. If the software
package is installed elsewhere, this provider is not flexible enough to
look for it. Ideally the file_path should be:

def self.file_path
   File.join( scope.lookupvar("splunk::params::forwader_confdir"),
'inputs.conf' )
end

But the provider is way too late in the game trying to access a value that
exists during compilation. So the catalog seems like the next best place
for figuring out where is splunk installed. After sleeping on it, I suppose
we can also write a setting file on the client system indicating where
splunk is installed, and read it back in the provider, but that seems like
such a round about way to get this info.

Thanks,

Nan

1.
https://github.com/puppetlabs/puppetlabs-splunk/blob/master/lib/puppet/provider/splunkforwarder_input/ini_setting.rb
2.
https://github.com/puppetlabs/puppetlabs-inifile/blob/master/lib/puppet/provider/ini_setting/ruby.rb#L5-L34

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/CACqVBqDvQv7YC1u-Kr_%3D%2Bp%2BoARiQ-qQGwG8n5BobdmpzSgQykA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to