Issue #7423 has been updated by Nick Fagerlund.
> ...I will let geppetto do the same – shortest matching name wins, and if
> there are more than one it is ambiguous.
Wait, are we saying the same thing here? I meant to say the longest one wins;
Puppet checks the full certname, then if it gets no node and the certname looks
like a FQDN, it'll chop off the highest-level domain and try again, until it's
down to a single word.
(Also, it looks like I didn't address ambiguous inheritance. The answer there
is that it's not ambiguous; when inheriting, you have to use the exact name of
the node. If you have both a `bugtracker.myorg.com` and a `bugtracker`, trying
to inherit `bugtracker` will always get you `bugtracker`. If you only have
`bugtracker.myorg.com` and `bugtracker.otherdivision.com` defined and you try
to inherit `bugtracker`, it'll blow up.)
> Is inherits with regexp on the right side ever used for any otherwise non
> achievable task?
I don't think so -- you could get everything you wanted from that by making an
inert base node and then inheriting it in all the regex nodes. I would be very
surprised if anyone has tried to inherit a regex node in anything but a "let's
try and break something" capacity.
> Does this work at all, or is the comparison then made with the magically
> stringified regexp as id? e.g.
>
> node a {}
> node ab {}
> node abc {}
> node x inherits /ab.*/ {}
That one doesn't work. You can't have an actual regex on the right side; only a
regular node name or regex node name (i.e. a stringified and munged regex). If
you had a node `/ab.*/`, you'd have to refer to it as "ab" (I think). (And if
you had a regular node "ab" like above, you couldn't also have an `/ab.*/`
node, lest all compilations fail.)
> Is it specified which \[matching regex node\] will win? or, just the one that
> the logic happens to check first?
In all my tests, it ends up being the one closest to the beginning of the file.
But there's not a spec, so that's technically just a coincidence.
Oh, also, I just noticed another thing I missed:
> Variable $y is not set to “yz”
>
> node a inherits “$y”
This will actually just blow up no matter what, it turns out: you can't use a
variable name in an inherits statement.
----------------------------------------
Bug #7423: unclear node inheritance semantics
https://projects.puppetlabs.com/issues/7423
Author: Henrik Lindberg
Status: Unreviewed
Priority: Normal
Assignee:
Category: parser
Target version: 2.6.x
Affected Puppet version:
Keywords: parser node inheritance semantics easeofuse documentation usability
Branch:
While working with Geppetto to provide validation and incremental feedback
while editing, I entered into the realm of node inheritance.
By looking at what is allowed in the grammar I have several questions regarding
the semantics and legality of some of the possible constucts.
I have no clue if the grammar should be more retrictive (i.e. these are grammar
bugs), or if the documentation should be expanded to declare how it is supposed
to work (or for that matter if any of these constructs actually work ;) - they
seem to be allowed from a grammar standpoint.
(If you prefer to read this online formatted a bit better - see
https://github.com/cloudsmith/geppetto/wiki/Semantic-Issues-regarding-Node-Inheritance)
### Can node ‘default’ inherit ?
A node declared as
node default { }
is used for hosts that do not match. Is it possible for such a node to also
inherit ?
node default inherits x { }
### Circular inheritance
Is obviously not allowed. Depending on the semantics for inheritance using
regular expressions, there can be some surprises that are introduced when
additional classes are added (and they happen to match).
### Ambiguous Nodes ?
Are simple and qualified names allowed to overlap? Is it ok to declare all of
these:
node bugtracker { }
node ‘bugtracker.myorg.com’ { }
node ‘bugtracker.internal.myorg.com’ { }
… or is this an error?
### Ambiguous inheritance
A node can be declared with a simple name (e.g. `bugtracker`), or a fully
qualified name (`‘bugtracker.myorg.com’`). When inheriting it is possible to
use both simple and qualified name - what happens when there are several to
choose from e.g. `‘bugtracker.myorg.com’`, `‘bugtracker.internal.myorg.com’`.
What happens if a node is declared with:
node x inherits bugtracker { }
### Nodes matching with regular expressions
A node can match using a regular expression:
node /web-([0-9]*).example.com$/ {}
How is inhertitance of such a node possible? This syntax is allowed by the
parser:
node webservers inherits /web-([0-9]*).example.com$/ {}
What does this mean? Is the inheritance to a node with an identical (matching)
regexp (i.e. equal regexp string), or to equivalently matching regexps, or it
is it applied to the regexp as a string? Or, are nodes defined with regexp
‘name’ not included in the matching?
This is very confusing...
### Can ‘default’ be matched with regexp?
Is this sensical?
node /defa.*/ { }
### Linking to non existing nodes
Since inheritence can be expressed with regular expressions and string
expressions - what happens if there is no match? Is this an error, or simply
that there is nothing to inherit at this particular moment? If the answer is
that it means that same as not having specified inheritance, then does the same
rule apply if a name is used? E.g.
1. No xyz is known
```ruby
node a inherits xyz { }
```
2. Regexp does not match
```ruby
node a inherits /x.*/ { }
```
3. Variably $y is not set to "yz"
```ruby
node a inherits "$y"
```
--
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.