On 20/09/16 15:54, R.I.Pienaar wrote:
>
>
> ----- Original Message -----
>> From: "jcbollinger" <John.Bo...@stJude.org>
>> To: "puppet-users" <
puppet...@googlegroups.com>
>> Sent: Tuesday, 20 September, 2016 15:37:21
>> Subject: Re: [Puppet Users] Re: notify resource different between 3 and 4?
>
>> On Monday, September 19, 2016 at 10:03:14 AM UTC-5, R.I. Pienaar wrote:
>>>
>>>
>>>
>>> On 19 Sep 2016, at 15:31, jcbollinger <John.Bo...@stJude.org <javascript:>>
>>> wrote:
>>> I see a difference between 3.8 and 4.6 with respect to the result of
>>> interpolating an array into a string. In Puppet 3 (and earlier) you get a
>>> concatenation of the stringifications of all the elements, whereas in
>>> Puppet 4, you get a more formatted representation. I would have expected
>>> such a change to be applied during a major version update -- so between 3.x
>>> and 4.0 -- but a quick browse of the release notes does not appear to
>>> mention it.
>>>
>>> This is not a puppet behaviour change. Newer Ruby does nicer looking to_s
>>> on arrays that's why
>>>
>>>
>>
It was a deliberate change in how interpolation is done. Earlier it was
unspecified and inconsistent. The change was introduced very early in
the life cycle of "future parser", and I believe it was documented then.
When 4.0 was released, many of the language changes were not release
noted. In some cases because it was impossible to define how it used to
work :-). For this particular change, there should probably have been a
note.
>> I'm prepared to believe that there's no Puppet code change, which would
>> explain why it's not documented in any release notes, but there's certainly
>> an observable behavior difference between the two example runs. If that is
>> not to be accounted a Puppet behavior change then I suppose it must also be
>> observable with (only) Puppet 3.8 running on different Ruby versions.
>> That's a nice gotcha if you happen to rely on interpolating arrays (not
>> that I would recommend doing so in any case).
>
The recommendation is to be explicit about how arrays and hashes should
be formatted if they are wanted in String form (Using either String.new
with a suitable format, or using the join function).
> yeah, and so you would I think, certainly recall people on IRC running into that.
>
>>
>> On the other hand, I observe that the current (4.6) Puppet docs document
>> the array interpolation format
>> <
https://docs.puppet.com/puppet/4.6/reference/lang_data_string.html#conversion-of-interpolated-values>,
>> independent of underlying Ruby. That may now be a distinction without much
>> practical difference, but it's the right thing to do: details of the
>> infrastructure -- and especially changes to them -- ought not to leak out
>> into Puppet's user-facing behavior. This sort of thing will become more
>> important as Puppet continues its movement away from Ruby as the main
>> implementation language.
>
> yup, this becomes a specified and supported way to do this and you can probably
> expect these to be properly treated in future.
>
Yes, now that it is specified it is part of the API.
Yes, the more advanced formatting stuff is intended to be the basic
building blocks for functions. The current support should be compared to
Ruby's Kernel#format. The surface level functionality is easy to use
though - for example things like String('%d', 42)
>
>> In any case, inasmuch as the OP was asking about behavioral differences, it
>> is highly relevant that the one observable difference of any significance
>> arises not because of a difference in the version of Puppet, but because of
>> a difference in the version of the Ruby underneath.
>
> Yeah, expect less of that as work moves toward C based compilers etc, this
> will make pinning every thing down to specified behaviour, good times.
>
Having the Puppet Language specification is key here.
- henrik
--
Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/