Re: [Puppet Users] Need help with defining same package resource in two modules

jcbollinger
Fri, 20 Sep 2013 13:08:42 -0000

On Thursday, September 19, 2013 4:59:51 PM UTC-5, Ryan Coleman
wrote:
>
>
> On Mon, Sep 16, 2013 at 10:49 PM, Mani Devarajan
<manide...@gmail.com<javascript:>
> > wrote:
>
>> How do i overcome this issue to complete the workflow of module B in
both
>> cases (where A is enabled or disabled)
>>
>
> Mani, virtual resources will get the job done but may be heavy-handed for
> your use case. If you want something a little simpler, check out the
> ensure_resource function provided by the puppetlabs/stdlib module (search
> the page for ensure_resource).
> http://forge.puppetlabs.com/puppetlabs/stdlib
>


Or don''t.  The ensure_resource() function does provide a simple
interface,
but like any other mechanism that directs catalog compilation by testing
the catalog under construction, it introduces an evaluation-order
dependency and therefore is fundamentally flawed.

As a threshold issue, the function only really addresses the problem if no
resource it protects is ever declared other than via that function or an
equivalent mechanism.  That may be relatively easy to control in a small,
all-custom manifest set, but it becomes harder to ensure the larger the
manifest set becomes, and doubly so as third-party modules are introduced
into the mix.

Then, even if a given package is only ever declared via ensure_resource()
or an equivalent mechanism, use of ensure_resource() defeats the purpose of
Puppet''s restriction on multiple declarations by allowing
*conflicting*declarations of the same resource.  If you fail to keep your
resource
declarations synchronized then you cannot easily predict which declaration
will be used, but more importantly, the other ones will NOT be used.  In
that case, then, the resource will *silently* fail to be in the state
expected by some of your modules.


John