Issue #16245 has been updated by eric sorenson.
OK I set up a testing rig to reproduce this.
<pre>
## puppet.conf
[master]
node_terminus = exec
external_nodes = $confdir/extnode.sh
## extnode.sh
#!/bin/zsh
cat <<EOF
---
classes:
- explosive
parameters:
port: :8080
## modules/explosive/manifests/init.pp
class explosive {
notify { "EXPLOSIVE": message => inline_template("port is a <%= @port.class
%>, inspect <%= @port.inspect %>") }
}
</pre>
Output shows that once that gets into ruby, the value becomes a symbol:
<pre>
/Stage[main]/Explosive/Notify[WE HAVE EXPLOSIVE]/message: defined 'message' as
'port is a Symbol, inspect :"8080"'
</pre>
----------------------------------------
Bug #16245: ENC output is sometimes internalized with variables as the wrong
types (str becomes int, etc)
https://projects.puppetlabs.com/issues/16245#change-72924
Author: Andrew Kesterson
Status: Investigating
Priority: Normal
Assignee: eric sorenson
Category:
Target version:
Affected Puppet version: 2.7.10
Keywords:
Branch:
We have an ENC that provides output in YAML format, and works 99.9% of the
time. We appear to have discovered a bug in the puppet YAML parser (or, rather,
whatever library puppet may be using to parse its YAML from the ENC). Our ENC
is written in python, all data is stored in JSON internally, and it uses the
pyyaml library to dump its output.
In this case, here is what we EXPECT to happen (in pseudocode):
In our ENC, define a string called "port":
{"port": ":8080"}
ENC provides output as YAML
port: ':8080'
puppet consumes ENC output
puppet says "That looks like a string"
puppet creates a global variable
$port = ':8080'
Unfortunately, here's what's REALLY happening:
in our ENC, define a string called port:
{"port": ":8080"}
ENC provides output as YAML, but pyyaml fails to quote the string (which,
according to the spec, appears to be fine?):
apiPort: :8080
puppet consumes ENC output
puppet has some behavior that causes the following to occur sometimes,
but not all the time (more data on this when I can get it):
puppet says "That value has a leading : on it; I need to parse that
some more, get rid of the :"
puppet says "That looks like an integer"
puppet creates a global variable
$port = 8080
The only way to fix this (from our ENC, at least) is to tell pyyaml's safe_dump
function to use the default flow style, which (according to pyyaml) does not
allow ":" to start any string, and will therefore quote any string that starts
with ":" (yes there is a specific exemption for this exact use case - funny).
And this does, indeed, fix the output; the string is quoted as it should be,
and puppet consumes the output happily, as a string, and no more confusion
occurs. HOWEVER, this is explicitly listed as a violation of the YAML
specification, and is a blatant hack, so we would prefer not to rely on it.
While the behavior of pyyaml here is questionable (and there may indeed be a
bug filed with them over this), the behavior of puppet's yaml parser does seem
to defy the standard; it seems that it should be consuming ":8080" as a string,
even if it is unquoted.
This is a rather pesky bug that is doing a very good job of destroying faith in
our ENC, and the idea that "what you put in the ENC is what you get in your
puppet module". Any plans to fix this in puppet 3? Is there a fix already that
I just don't know about?
--
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.