I disagree that ensure_resource is evil and should not be used. It is
however, potentially problematic, and it's issues are worth discussing. It
was written (full disclosure by me) as an improvement over defined(). While
it is not perfect (it suffers from parse-order issues), it is intended as
an improvement of defined, a convenience method which exists in Puppet
core.

Specifically, it is intended to solve the limitation in Puppet that
duplicate resource declarations are treated as failures in Puppet, even if
the resources they describe are identical.

That being said, there are two reasons it may be problematic.

1. Behavior depends on parse order - this is probably the best reason not
to use it. The behavior of how it will fail depends on the order in which
code is parsed in Puppet. That is why this method (as well as defined(),
and resource collection overrides) should only be used by users who
understand this behavior, it's limitations, and how to debug it when they
run into issues. It's usage and the fact that it depends on the order in
which your code is parsed makes it problematic to have in modules that are
intended to be shared. That being said, it looks like Puppet is moving to a
more procedural language,which may make this less of an issue going forward.

2. It is not part of Puppet core and may need access to unsupported APIs to
work as expected. I was not aware until I read that email thread that it
was not working correctly with parameter aliases, it's pretty reasonable to
open this up as an issue and see if someone volunteers to fix it. That
being said, I think it will require access to some undocumented unsupported
APIs in order to implement correctly.




On Mon, Mar 31, 2014 at 7:08 AM, jcbollinger <john.bollin...@stjude.org>wrote:

>
>
> On Sunday, March 30, 2014 11:24:30 PM UTC-5, Atom Powers wrote:
>
>> Over the years I've heard a lot of people declare one
>> function/method/implementation of something to be "evil". I've found that,
>> more often than not, the person declaring it to be bad has simply been
>> burned by trying to use it for something the function was never intended to
>> be used for. (Usually an easy trap due to incomplete documentation.)
>>
>> So I wonder, are ensure_resource and create_resources really evil, or
>> just too easy to abuse in evil ways?
>>
>>
>> On Fri, Mar 28, 2014 at 9:06 AM, jcbollinger <john.bo...@stjude.org>wrote:
>>>
>>>
>>> Ensure_resource() is evil.  Do not use it.
>>>
>>
>>
> Ensure_resource() is evil.  Create_resources() is not.   The post from
> which you excerpted my comment (
> https://groups.google.com/forum/#!searchin/puppet-users/ensure_resource/puppet-users/dOCIZ8-Gfgw/VhlBbrSRpb8J)
> explains why ensure_resource() is evil: in short, because it looks like it
> does something useful, but in fact hands you a gun loaded with foot-seeking
> bullets.  It takes *at least* as much work to use ensure_resource()
> safely as it does to avoid any need for it in the first place.
>
>
> John
>
>  --
> 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 puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/f5d5c0aa-2355-4dc8-91da-2311fc3f679a%40googlegroups.com<https://groups.google.com/d/msgid/puppet-users/f5d5c0aa-2355-4dc8-91da-2311fc3f679a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CA%2B0t2LxOkQOosGsGuDRSWc24jq8t%2BUa2CXuV10SkSQK8DMCREg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to