Thanks John,
                       I actually got it working exactly using 
hiera($users) and then defining a resource and passing the array to the 
defined resource which makes it run for every element of the array.
I guess that was again one of your post, where you have described the 
approach to perform iterations in puppet
http://www.mail-archive.com/[email protected]/msg29238.html


Can you please provide some good links to the tutorials where I can learn 
more about using hiera, as it looks to me like one of the major souce of 
externalizing data.


Thanks,
Nishant
.
On Friday, October 12, 2012 4:26:43 PM UTC-4, jcbollinger wrote:
>
>
>
> On Friday, October 12, 2012 9:52:01 AM UTC-5, Nishant Jain wrote:
>>
>> 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'),
>>                 }
>>
>>
>
> Yes, I gathered that from your earlier description.  That directs Puppet 
> to manage a file /tmp/nish_lat on the client, whose content is the string 
> value of the object obtained by invoking hiera('users').  I inferred that 
> you were doing that to check the value hiera was returning, hence I 
> suggested a slightly less kludgy approach to that.
>
>  
>
>>                  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.
>>
>
>
> If you mean that was the purpose of the File resource then you going in a 
> very wrong direction.  Hiera itself is a way (a good one) to read an array 
> from a file, as it seemed you understood.
>
>  
>
>>             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
>>
>
>
> That error message suggests that Puppet variable $users is unset or 
> explicitly set to nil.  Either you missed the line that sets the $users 
> variable (to the value returned by "hiera('users')"), or you changed your 
> data or your hiera configuration, or you ran the test in a different 
> context than your earlier one.
>
>  
>
>>              
>>                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.
>>
>
>
> The very simplest form of doing that in Puppet would be something like 
> this:
>
> ######
> $users = hiera('users')
>
> user { $users: }
> ######
>
> That's far too simple for practical use, of course, but it demonstrates 
> the basic idea of obtaining data from an external file (via hiera, in that 
> case) and using it to declare possibly-multiple resources.  There is also a 
> variation that loads data as a hash of hashes and uses the 
> create_resources() function instead of an explicit resource declaration:
>
> ######
> $users_hash = hiera('user_data')
>
> create_resources('user', $users_hash)
> ######
>
> Anything else is an embellishment on one of those basic themes.
>
> Note that managing the contents of a File resource cannot influence 
> anything about other resources included in the target node's catalog.  The 
> catalog is compiled before any of its contents are applied (and on the 
> master in a master / client setup), and that determines all the resources 
> and their managed properties.  I assumed you understood that, which is why 
> I interpreted your File resource as a test mechanism.  If you didn't know 
> before then you do now.
>
>
> 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/-/DR-AA5p_s0wJ.
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.

Reply via email to