Yep, I was thinking of doing exactly this, but it seemed that it could be useful in other cases.
Trevor On Thu, Jul 25, 2013 at 6:18 PM, Nan Liu <[email protected]> wrote: > On Thu, Jul 25, 2013 at 2:21 PM, Trevor Vaughan <[email protected]>wrote: > >> Ok, so I'm not sure how this proposal will go over but I'm going to throw >> it out there. >> >> I recently encountered a situation where I was using the stdlib function >> 'file_line' to manage one line in a file but, through various means, ended >> up managing the entire file when using the code base i a different way. >> >> What I would like to propose is the addition of two metaparameters to >> correlate with the code smell of defined(). >> >> I hate defined() because it's code order dependent. So, I would like to >> add is_active and is_inactive as metaparameters that use the actual catalog >> state to determine whether or not to run the resource. >> >> Example: >> >> file { '/tmp/foo': content => "foo\nbar" } >> file_line { 'test': >> path => '/tmp/foo', >> line => 'foo' >> } >> >> As you can see from this contrived example, these two resources will >> constantly fight. >> >> However, if we do the following: >> >> file { '/tmp/foo': content => "foo\nbar" } >> file_line { 'test': >> path => 'tmp/foo', >> line => 'foo', >> is_inactive => File['/tmp/foo'] >> } >> >> Then, file_line will only execute if the File['/tmp/foo'] resource is not >> in the catalog. Otherwise, it should just log a debug message that it is >> not executing due to the is_inactive metaparameter. >> > > Since path == is_inactive, and I can't see an exception in this case, > couldn't you just enhance file_line path parameter to validate if > catalog.resources contains a reference to File[resource[:path]] with > content or source specified? > > Nan > > -- > 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 post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/puppet-dev. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Trevor Vaughan Vice President, Onyx Point, Inc (410) 541-6699 [email protected] -- This account not approved for unencrypted proprietary information -- -- 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 post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/puppet-dev. For more options, visit https://groups.google.com/groups/opt_out.
