Issue #21432 has been updated by Charlie Sharpsteen.

Category set to language
Status changed from Unreviewed to Duplicate
Assignee set to Charlie Sharpsteen
Keywords set to namespace

This is a duplicate of #13349 which was resolved by the scoping re-work that 
happened for Puppet 3. The issue is that when confronted with 
`class{'::foo'}:`, certain situations will cause Puppet 2.7.x to pop the 
leading colons off of the resource reference and attempt a second namespace 
lookup that will bump into locally defined classes.

Solutions are:

  - Upgrade to Puppet 3, which has much saner scoping and namespace resolution.

  - Use `include ::foo` instead of `class{'::foo':}`. You may need to deploy 
[the anchor 
pattern](http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html) 
to enforce proper ordering of included classes.

----------------------------------------
Bug #21432: Class declaration scope issue
https://projects.puppetlabs.com/issues/21432#change-93633

* Author: Mickaël Canévet
* Status: Duplicate
* Priority: Normal
* Assignee: Charlie Sharpsteen
* Category: language
* Target version: 
* Affected Puppet version: 
* Keywords: namespace
* Branch: 
----------------------------------------
Hi,

I have a strange issue in puppet 2.7(.19 and .22) that I don't have with puppet 
3(.0.0 and .2.2):

First I install puppetlabs-postgresql in a temporary directory:

<pre>
mkdir modules
puppet module install --modulepath modules puppetlabs-postgresql
</pre>

Then I test this simple code:

<pre>
puppet apply --noop --modulepath=modules/ -e "class {'::postgresql': } -> class 
{'::postgresql::server': }"
</pre>

It works (at least it compiles).

Then I create a simple module:

<pre>
mkdir -p modules/my_module/manifests
</pre<

with a simple class doing the same thing as above:

</pre>
cat << EOF > modules/my_module/manifests/pgsql.pp
class my_module::pgsql {
  class {'::postgresql': } -> class {'::postgresql::server': }
}
EOF
</pre>

When I try to apply it, it works:

<pre>
puppet apply --noop --modulepath=modules/ -e "include my_module::pgsql"
</pre>

But if I create another class my_module::postgresql, it fails:

<pre>
cat << EOF > modules/my_module/manifests/postgresql.pp
class my_module::postgresql {
  class {'::postgresql': } -> class {'::postgresql::server': }
}
EOF
</pre>

With this error message:

<pre>
puppet apply --noop --modulepath=modules/ -e "include my_module::postgresql"
Duplicate declaration: Class[Postgresql::Params] is already declared; cannot 
redeclare at modules/postgresql/manifests/init.pp:144
</pre>

And now if I launch this:

<pre>
puppet apply --noop --modulepath=modules/ -e "include my_module::pgsql"
</pre>

I get:

<pre>
Duplicate declaration: Class[Postgresql] is already declared in file 
modules/my_module/manifests/pgsql.pp at line 2; cannot redeclare at 
modules/my_module/manifests/postgresql.pp:2 on node wrk8.wrk.lsn.camptocamp.com
</pre>

I think that in some case the '::' prefix before 'postgresql' is not well 
interpreted.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to