Hello jcbollinger,
I am actually trying to read the array into a
variable and passsing that variable as the content of a file like below,
file{'/tmp/nish_lat':
ensure=>file,
content=>hiera('users'),
}
My intention was to just get a way to read the array from
a file, so that I can pass it to a define resource , where it can be used
to create a no of resources, as there are no loops available in puppet.
I have tried using your method of notifying, but it sends out
an error
Error 400 on SERVER: Failed to parse inline template:
undefined method `join' for nil:NilClass
I am actually new to puppet and my work as of now is to be
able to create a no of users on a machine based on the information passed
to it from a file.
Thanks,
Nishant
On Friday, October 12, 2012 9:19:43 AM UTC-4, jcbollinger wrote:
>
>
>
> On Thursday, October 11, 2012 2:02:31 PM UTC-5, Nishant Jain wrote:
>>
>> Thanks Everybody, I got it working, but am still not able to read the
>> array using hiera. It always read the last element of the array.
>> For example in the following global.yaml file:-
>> ---
>> users:
>> - 'seventeen'
>> - 'eighteen'
>>
>>
>> when i write hiera('users') and print it as a content it a file, It
>> always write eighteen in the file, instead of seventeen , eighteen.
>>
>>
>> It always read the last value, i.e. eighteen.
>>
>> Any idea how I can make it read the whole array.
>>
>
>
> If the hiera config and data is indeed as you posted, then the problem is
> not on the reading side, but rather on the writing side. You did not show
> how you are trying to output the result, but here's one way you can test:
>
> $users = hiera('users')
> notify { "debug user list":
> message => inline_template('<%= @users.join(",") %>')
> }
>
> Look for the result in the client-side log. Note, too, that there is a
> 'join' function in PuppetLabs's 'stdlib' add-in module. That would be more
> convenient to use than inline_template(), but inline_template() should work
> with Puppet straight out of the box.
>
>
> John
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/zudCLEGmrGcJ.
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-users?hl=en.