"signalling" inside a puppet provider?

13 views
Skip to first unread message

Peter Berghold

unread,
Dec 1, 2015, 10:48:49 AM12/1/15
to puppet-users
Given the following pattern in a puppet manifest: 

file{ 'some/file/foo':
      content => 'blah blah blah',
      notify => Exec['talkaboutfoo']
}
exec { 'talkaboutfoo':
     cmd => "some/command/some/where",
     subscribe => File['some/file/foo']

with a little bit of hand waving. 

Is there something similar in a custom provider?  Reason I'm asking is I have 
written a custom provider for a very customized piece of locally grown software that ideally one of the configuration parameters 

mytype{ 'instance':
     state => "on",          # this parameter
     parm1=> "a",
     parm2=> "b",
     parm3=>"c"
}

should be set *last* among all the other parameters.  

Is there a way to do that?

Branan Riley

unread,
Dec 3, 2015, 2:05:42 PM12/3/15
to puppet...@googlegroups.com
Hi Peter,

You can do this by implementing a `flush` method on your provider. The typical pattern is that each individual property setter just stores the value into an instance variable that is a hash of property_name=>value pairs (normally called @property_hash), and then `flush` does all the work of actually writing those values. This will allow you to order the actual interactions with the real world however you need.


Gary Larizza's blog has some great posts on Provider development - http://garylarizza.com/blog/2013/12/15/seriously-what-is-this-provider-doing/ contains the information on @property_hash, but if you're new to writing types and providers I'd recommend reading the first two (linked from that one) as well to make sure you have all the context.


Branan Riley
Software Engineer, Puppet Labs
Reply all
Reply to author
Forward
0 new messages