can Puppet differentiate between a scalar and a single element array as a resource attribute?

asked 2014-10-19 14:07:50 -0600

nrser gravatar image

updated 2014-10-20 17:31:51 -0600

is there a way to make Puppet to differentiate between

my_custom_type { 'key':
  value => 'blah',


my_custom_type { 'key':
  value => ['blah'],

when declaring resource attributes?

this is for a custom type, so i have full ruby-land control, but both show up to Puppet::Type#set_parameters and consequently Puppet::Property#should= as 'blah'.

i'm using Puppet 3.4.3 on top of Ruby 2.0.0

CONTEXT: the custom type I'm implementing edits Apple property lists (.plist files), where a string and an array containing a single string element are quite different.

declaring the property like

newproperty(:value, :array_matching => :all) do

along the lines of

doesn't seem to change what set_parameters or should= receive, they just make Puppet::Property#should return ['blah'] instead of 'blah' in both cases. it appears the differentiation is tossed out further up at the parser level.


my_custom_type { 'key':
  value => [['blah']],

doesn't help either - same result.


i realize i can work around this by providing additional information in the declaration, like so:

my_custom_type { 'key':
  value => ['blah'],
  is_array => true,


my_custom_type { 'key':
  value_array => ['blah'],

i'm wondering if there is a way to capture whether an array or scalar was declared... though feel free to explain to me why doing so would be unwise or heretic in Puppet-world; i'm a little new to this strange place.

edit retag flag offensive close merge delete


what version of Puppet? What version of Ruby?

llowder gravatar imagellowder ( 2014-10-20 07:23:06 -0600 )edit

@llowder sorry, i'll edit it in there... Puppet 3.4.3 and Ruby 2.0.0

nrser gravatar imagenrser ( 2014-10-20 17:30:38 -0600 )edit