You're right, you're not the first to suggest this. You will find multiple discussions on this topic in the archives of this group and of the developers group. The most recent one I recall was in the context of a discussion of changes to the syntax and semantics for resource declarations for (then-future) Puppet 4. Some of the ideas from that discussion were in fact implemented, but not the ones around reducing the duplicate declaration problem. Perhaps the existence of
ensure_resource() was considered to adequately address that aspect already.
Of course, this is primarily a module compatibility issue, for within a single code base, it is entirely feasible to solve the problem via one of
the means Puppet recommends. In a more general context, some of the same ideas still apply -- in particular, it makes some sense to approach the problem by stipulating that there shouldn't
be a problem: instead, there should be at most one class (and therefore one module) in any manifest set responsible for any given resource, and the only way that resource it should be managed is via that class. Other modules would depend on the designated module / class instead of managing the resource directly. But that solves the problem by kicking it up a level, making it one of module
set design and curation.
In the end, I think the biggest problem with the suggestion of changing resource declaration semantics to match the semantics of
ensure_resource() is that despite being a substantial semantic shift, it would not completely solve the problem. It would handle the case of multiple
identical resource declarations but not cases of multiple
compatible declarations. This latter is quite a hard problem, because it is not clear
a priori what makes non-identical declarations compatible. I once had some ideas on this topic that I still think are pretty good, though fully implementing and using them would be much more disruptive at this point than when I first suggested them. Nevertheless, you might find
this discussion of interest. Felix Frank later
implemented some of those ideas.
I'm game to have this discussion again in the context of present-day Puppet and its ecosystem, but inasmuch as Puppet, Inc. has had multiple suggestions and ample opportunity to make the changes you seem to want, and has not made them, I think it's a lost cause.
John