On Tue, 30 Apr 2013 15:37:11 -0700
Ryan Uber <[email protected]> wrote:

> [accidently sent this to puppet-dev, re-posting to puppet-users]
> 
> Hello puppet-users,
> 
> I am working on a module that provides a custom type. The type when
> called will create new resources in the catalog using syntax like:
> 
> Puppet::Type.type(:file).new(:title => 'blah')
> 
> This works fine and the resources are added as expected. However, I am
> unable to apply any scoped defaults to the generated resources. So
> something like:
> 
> File {
>   mode => 0750
> }
> 

were do you generate the resources? Puppet already has a method
"eval_generate" that every type can implement and which has to return
an array of generated resources (that's how puppet generates implicit
file resource when you use `recurse`). These resources are
automatically added to the catalog.

So e.g.

    Puppet::Type.newtype(:foo) do
      newparam(:name)
      [...]
      def eval_generate
        resources = []
        resources << Puppet::Type.type(:file).new(:title => 'blah')
        resources
      end
    end

I played with it a little bit (wanted to make a proof of concept for
a `dirtree` type that simulates the behaviour of `mkdir -p`) but I hit
problems because autorequirements of generated resources do not seem to
work (e.g. You have File['/foo'] in your puppet manifest and your
custom type generates a resource File['/foo/bar'] there a no automatic
dependencies so File['/foo/bar'] may be applied before File['/foo'] but
maybe I am wrong about that one.

-Stefan

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


Reply via email to