I'm trying to use the existing type: file in a custom provider.  I've
tried about every single thing I can find, and each way presents a
different problem.

Here's how it looks now:

---
require 'puppet/file_serving/configuration'
require 'puppet/file_serving/fileset'
require 'puppet/type'
require 'fileutils'

Puppet::Type.type(:tmfile).provide(:pupfile) do
    def create
        @catalog.add_resource Puppet::Type.type(:file).new({
            :name   => @resource.value(:path),
            :path   => @resource.value(:path),
            :source => @resource.value(:source),
            :ensure => 'present',
        })
        @catalog.apply
        #def generate
        #Puppet::Type.type(:file).new(:path =>
resource[:path], :source => resource[:path], :ensure => 'present')
        #end
    end

    def destroy
        FileUtils.rm_rf resource[:path]
    end

    def exists?
        File.exists?(@resource[:path])
    end

end
----

As you can see, another method I tried is commented out:
Puppet::Type.type(:file).new(:path => resource[:path], :source =>
resource[:path], :ensure => 'present').  With this method, the puppet
run actually succeeds and it says it created the resource.  However,
the file doesn't actually get created, and next run, it simply creates
the resource again without error.  However, the file is never there.

With the current method (not commented out), I get:
".. ensure: change from absent to present failed: Could not set
'present on ensure: undefined method `add_resource' for nil:NilClass
at .."

I will admit that I'm pretty new at custom types and providers.  I
have researched as much as I can but can't really find any clear
documentation on how to do this.  Any ideas/suggestions would be
greatly appreciated!

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to