On 10/14/2012 04:20 PM, Jakov Sosic wrote:
On 10/14/2012 03:01 PM, Stefan Schulte wrote:
If you use "ensurable", puppet will expect the provider to have an
exists? method and if that returns true your create method will not be
called so you do not have to check the existance in the create method
again.

But then I would have to change all params to properties and add
appropriate methods to provider, but that would both slow it down and
complicate it more... I don't know if it's worth it just for the sake of
log message stating "property changed from A to B" instead of
"cobblersystem created" on every param change.


If adding interfaces to a new host is exactly the same as changing
interfaces of an already existing host you can call

     interface = resource[:interface] if resoure[:interface]

I'll try that.


First of all I renamed "interface" to "interfaces", and then I've found solution for adding the property in first run, here is what code looks like:

        # add interfaces
        unless self.interfaces == @resource.should(:interfaces)
            self.interfaces = @resource.should(:interfaces)
        end

It's documented here:
http://projects.puppetlabs.com/projects/puppet/wiki/Development_Complete_Resource_Example

I forgot about documentation :)

So I guess I could be rewriting all of my params to properties now, hm...


--
Jakov Sosic
www.srce.unizg.hr

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

Reply via email to