Hello,
this is somewhat related to

https://groups.google.com/forum/?hl=it&fromgroups#!topic/puppet-users/uqZKLikYbJs

but I wanted to ask since it seems a more general issue.

with puppet 2.7.14, puppet-module-tool has been pulled into core puppet,
hence I think pre-cooked modules will become more and more widespread
and used.

But there's a namespace issue with resources; while classes got their
own namespace system, and dynamic variable lookup is being deprecated,
this doesn't hold true for resources.

Consider the following example:

Module one contains this in init.pp

class one {
   file { 'something':
        path => '/tmp/that'
        }
}

module two contains this in init.pp

class two {
   file { 'something':
        path => '/tmp/this'
        }
}


As a result, somebody using both modules would get an error like:

err: Could not retrieve catalog from remote server: Error 400 on SERVER:
Duplicate declaration: File[something] is already declared in file
/etc/puppet/modules/one/manifests/init.pp at line 17; cannot redeclare
at /etc/puppet/modules/two/manifests/init.pp:19 on node xxx.yyy.zzz

Even though there's no real issue here, and the user shouldn't be forced
to change the code of external modules, IMHO.

It seems that resource types work this way:

- resources are pulled in a global namespace and must be unique with a
"primary key" like (resource type, resource name). This includes aliases
- you can't create an alias name that's not unique (that makes sense).
- if the namevar parameter is not assigned explicitly, use title as
namevar. The resource name will be called just like the title.
- if the namevar parameter is assigned, the resource will be *aliased*
to the namevar value.
- if an alias parameter is assigned, such alias will be *added* to the
ones the resource may already have.

IMHO again:

* such behaviour may be puzzling. If I give a title to a resource, I
expect conflicts to be checked against that name, not against the
namevar that - very often - is highly semantic, e.g. I must use path
with files, otherwise I can't tell the system where to put the file; so,
a useful metadata check ("don't reuse the same name") becomes tied to a
semantic behaviour I can't change.

I think the name checks should be performed after title and aliases
only, not after the namevar, which is something internal.

There may be even cases where I want to use multiple resources with the
same target (e.g. I might want to use two file{} with the same path but
one for content, the other for setting permissions, depending on the
situation, by setting the proper Require =>), and this would prevent me
from doing that.

* non-scoped resources can generate name conflicts everywhere, even
though they're not useful.

I think resource scoping is highly needed if modularization is the way
to go for puppet.

-- 
Latest blog post: Deploying WAR on Heroku http://t.co/M4krW2Mu
contact me at public@[mysurname].eu

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to