Should package {...} check if identical package is declared before?

33 views
Skip to first unread message

tan...@gmail.com

unread,
Mar 19, 2015, 9:56:38 AM3/19/15
to puppet...@googlegroups.com
I've encountered the problem where 2 modules declare the identical package. 

I wonder why package { .. } doesn't check if the package is already declared, and the redundant declaration can be ignored.

Will it be a nice improvement? If not, why not?

Thank you,
Tanin

Peter Kristolaitis

unread,
Mar 19, 2015, 10:08:42 AM3/19/15
to puppet...@googlegroups.com
From this example:

package { 'foo':
    ensure => '1.0.0',
}

package { 'foo':
    ensure => '1.0.1',
}

package { 'foo':
    ensure => 'latest',
}

Which one wins?  Since resources can be evaluated and applied in any order (barring dependencies), you could end up in a situation where a package gets flipped between different versions on subsequent runs of the agent.  It breaks the idea of being idempotent.
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/aeaf617d-aeb0-47f9-9997-69544489b8e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jcbollinger

unread,
Mar 20, 2015, 9:10:05 AM3/20/15
to puppet...@googlegroups.com
It has been requested before, in various forms.  The case is pretty clear cut where the conflicting resources have different parameters: Puppet must throw an error because there is no catalog that can represent the conflicting constraints of all the different declarations of the same resource.  It is not ok to just choose one, because then Puppet would not be enforcing some of the state specified to it.

The arguments around identical resource declarations are less clear cut, but they don't apply to your situation.  Your declarations are differentiated simply by their locations.  Every resource is automatically assigned a set of tags, some of which are derived from the location of its declaration.  These tags cannot be neglected because they can have a profound effect on how the catalog is applied and even on how it is built.  Thus, identical package (or other resource) declarations in different classes do not declare identical resources.


John

Reply all
Reply to author
Forward
0 new messages