Bug #1754
puppet magically doesn't evaluate certain (special named) included classes
| Status: | Rejected | Start date: | 11/17/2008 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | language | |||
| Target version: | - | |||
| Affected Puppet version: | 0.24.5 | Branch: | ||
| Keywords: | ||||
| Votes: | 0 |
Description
given the following manifest:
class php {
fail("php")
}
class apache::foobar::php {
notice("yeah2")
include php
}
class apache::foobar::webhosting_php {
include apache::foobar::php
}
class somehost {
include apache::foobar::webhosting_php
}
include somehost
notice("yeah")
and running it with puppet will not give the expected result:
# puppet foobar.pp notice: Scope(Class[apache::foobar::php]): yeah2 notice: Scope(Class[main]): yeah
imho puppet should fail as the php class has clearly a fail statement.
I discovered this while debugging a certain host because it didn’t install php on it. the includes are similar to this lab setup, however spreaded over modules and different files. But I get the same result putting notices in the different parts as in the lab setup.
Currently I have no idea how to debug this further nor where exactly the problem may lie. As the classes are named somehow similar to address the needed functionality I had the idea that this might “confuse” puppet. So I tested the following manifest:
class test {
fail("php")
}
class foobar {
notice("yeah2")
include test
}
class blah {
include foobar
}
class somehost {
include blah
}
include somehost
notice("yeah")
which fails as expected:
# puppet foobar.pp notice: Scope(Class[foobar]): yeah2 php at /tmp/foobar.pp:2 on node foobar
So I definately think that this is a problem of the evaluation as putting a syntax error in the php class will fail puppet to parse the manifest.
either debug nor trace statements give more information.
Behaviour have been reproduced on:
- 0.24.5
- 0.24.6
- HEAD
History
Updated by AJ Christensen over 3 years ago
- Category set to language
- Status changed from Unreviewed to Accepted
Can confirm this behavior on 0.24.6 (via Git tag) and 0.24.x HEAD.
Updated by Luke Kanies over 3 years ago
Use ‘include ::php’ if you want this to work. Puppet’s just ignoring your attempt to have a class include itself. You might need to quote the class name in the ‘include’, I can’t remember.
If you think this should throw a warning or something, please open a new ticket with a more clear description.
Updated by Peter Meier over 3 years ago
Use ‘include ::php’ if you want this to work. Puppet’s just ignoring your attempt to have a class include itself. You might need to quote the class name in the ‘include’, I can’t remember.
hmm what do you mean with “a class include itself”
class php {
fail("php")
}
class apache::foobar::php {
notice("yeah2")
include "::php"
}
class apache::foobar::webhosting_php {
include apache::foobar::php
}
class somehost {
include apache::foobar::webhosting_php
}
include somehost
notice("yeah")
which leads still to the same issue:
# puppet foobar.pp notice: Scope(Class[apache::foobar::php]): yeah2 notice: Scope(Class[main]): yeah
Updated by Luke Kanies over 3 years ago
As explained on IRC, the class’s name is ‘php’, with the namespace of ‘apache::foobar’. In a class named ‘php’, you’re trying to include a class named ‘php’. Since classes are singletons, this is a no-op. If you want to skip the namespace, use ‘::php’.
Updated by Peter Meier over 3 years ago
- Status changed from Accepted to Rejected
luke wrote:
As explained on IRC, the class’s name is ‘php’, with the namespace of ‘apache::foobar’. In a class named ‘php’, you’re trying to include a class named ‘php’. Since classes are singletons, this is a no-op. If you want to skip the namespace, use ‘::php’.
the last suggestion doesn’t work either. but we’ll address this bug in a new ticket.