iteration in future parser doesn't handle hashes as documented

65 views
Skip to first unread message

Jo Rhett

unread,
Feb 15, 2015, 5:49:21 PM2/15/15
to puppet...@googlegroups.com
From documentation at https://docs.puppetlabs.com/puppet/latest/reference/experiments_lambdas.html

For a hash:

If two parameters are used, they will be set to the key and value of each hash entry. If one parameter is used, it is set to an array containing [key, value].

With Puppet 3.7.4 this doesn’t work as documented:

$ facter | grep system_uptime
system_uptime => {"uptime"=>"1:04 hours", "days"=>0, "hours"=>1, "seconds"=>3898}

$ cat iter.pp 
each( $facts['system_uptime'] ) |$key, $value| {
  notice "$key = $value"
}

$ puppet apply iter.pp 
Notice: Scope(Class[main]): 0 = s
Notice: Scope(Class[main]): 1 = e
Notice: Scope(Class[main]): 2 = c
Notice: Scope(Class[main]): 3 = o
Notice: Scope(Class[main]): 4 = n
Notice: Scope(Class[main]): 5 = d
Notice: Scope(Class[main]): 6 = s
(snip)

The hash is clearly being recast as a single long string passed into an indexed array.

-- 
Jo Rhett
+1 (415) 999-1798
Skype: jorhett
Net Consonance : net philanthropy to improve open source and internet projects.

Jo Rhett

unread,
Feb 15, 2015, 5:52:30 PM2/15/15
to puppet...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/EA1FCAEB-38D7-48F7-8832-A81C18A24001%40netconsonance.com.
For more options, visit https://groups.google.com/d/optout.

Henrik Lindberg

unread,
Feb 15, 2015, 7:30:40 PM2/15/15
to puppet...@googlegroups.com
On 2015-15-02 23:52, Jo Rhett wrote:
> Opened as https://tickets.puppetlabs.com/browse/PUP-4015
>

You are bit by "stringify_facts" (see ticket for explanation).

- henrik

> On Feb 15, 2015, at 2:49 PM, Jo Rhett <jrh...@netconsonance.com
>>> *For a hash:*
>> <mailto:puppet-users...@googlegroups.com>.
>> <https://groups.google.com/d/msgid/puppet-users/EA1FCAEB-38D7-48F7-8832-A81C18A24001%40netconsonance.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> Jo Rhett
> +1 (415) 999-1798
> Skype: jorhett
> Net Consonance : net philanthropy to improve open source and
> internet projects.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/D5F46694-BFCA-447D-A666-582E1BB04B1D%40netconsonance.com
> <https://groups.google.com/d/msgid/puppet-users/D5F46694-BFCA-447D-A666-582E1BB04B1D%40netconsonance.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Reply all
Reply to author
Forward
0 new messages