PuppetDB type casting wierdness

19 views
Skip to first unread message

Simon Murray

unread,
Oct 12, 2015, 10:51:03 AM10/12/15
to Puppet Users
Given a site.pp that looks like this:

define test_type (
  $value = [],
) {
  $type = inline_template('<%= @value.class %>')
  notify { "${title} => ${type}": }
}

@@test_type { $::fqdn:
  value => [ $::fqdn ],
}

Test_type <<||>>


I get the odd result when run on icinga:

Notice: icinga.angel.net => Array
Notice: puppet.angel.net => String

Seemingly when my type is collected from puppetdb, somewhere in the chain an implicit type cast occurs.  It only seems to occur with arrays containing a single element.

Kind of annoying in that I can't put type validation in the defined type and have to 'Array(@value)' in templates.  Can't seem to find any mention of this behaviour, any pointers?

DataCentred Limited registered in England and Wales no. 05611763

Wyatt Alt

unread,
Oct 12, 2015, 11:17:53 AM10/12/15
to puppet...@googlegroups.com, Simon Murray
You're encountering PDB-170 (https://tickets.puppetlabs.com/browse/PDB-170.)

It's a known bug, and last time I looked at it wasn't clear whether the
issue was Puppet or PDB, but I just tried it on Puppet 4.2.2/PuppetDB
3.1.0 and I can't reproduce:

https://gist.github.com/wkalt/83d8d8170d9f20aad331

so I'm thinking it may have been fixed on the Puppet side. What versions
are you running?

Wyatt

Simon Murray

unread,
Oct 13, 2015, 5:36:06 AM10/13/15
to Wyatt Alt, puppet...@googlegroups.com
Thanks Wyatt, my google fu is weak :)

I'm stuck on puppetserver 1.1.1 and puppetdb 2.3.7 for the time being in my dev environment.
I'll upgrade to the PC1 packages once I've got this current code deployed into production and see if it makes life easier.
Then begins the task of upgrading production...
Reply all
Reply to author
Forward
0 new messages