Thanks, Steven.
I will try it out
On Feb 3, 2013, at 10:21 PM, Steven Nemetz wrote:
> You can read the hash directly, create_resource is not needed (may or may not
> be desired)
>
> $user_defs = hiera('os_users') will give you the full hash
>
> What I tend to do for this type of data structure is:
>
> $user_defs = hiera('os_users')
> $user_keys = keys($user_defs)
> if is_array($user_keys) {
> process_users { $user_keys:; }
> }
>
> define process_users {
> # Do whatever you want for each element of the hash
> # $name will be the hash key
> # $user_defs[$name] is the hash of the current item
> # $user_defs[$name]['comment'] to access the user's comment field
> }
>
>
> Steven
>
>
> From: [email protected]
> Subject: Re: [Puppet Users] hiera query yaml parameters
> Date: Sun, 3 Feb 2013 19:19:25 -0500
> To: [email protected]
>
> Could you show your solution, please ?
>
> I would like to see how you did it.
>
> On Feb 3, 2013, at 6:46 PM, roadtest wrote:
>
> I figure out the solution.
>
> Using the create_resource to convert YAML to a hash array, then I can query
> retrieve every individual value. If there is better way, feel free to share
> with group.
>
> carl
>
> On Saturday, February 2, 2013 3:25:33 PM UTC-5, roadtest wrote:
> Hello,
>
> I have a yaml data file containing user account with following information.
> #more users.yaml
> ---
> os_users:
> user1:
> locked: false
> comment: System Operator
> uid: '700'
> gid: '700'
> groups:
> - admin
> - sudonopw
> sshkeys:
> - ssh-rsa
> AAAAB3NzaC1yc2EAAAABIwAAAQEAwLBhQefRiXHSbVNZYKu2o8VWJjZJ/B4LqICXuxhiiNSCmL8j+5zE/VLPIMeDqNQt8L
> user2:
> locked: true
> comment: Test Locked Account
> uid: '701'
> gid: '701'
> groups:
> - admin
> - sudonopw
> sshkeys:
> - ssh-rsa
> AAAAB3NzaC1yc2EAAAABIwAAAQEAwLBhQefRiXHSbVNZYKu2o8VWJjZJ/B4LqICXuxhiiNSCm
>
> I can search os_users information like following:
> #hiera -c /etc/hiera.yaml os_users
> {"user1"=>{"groups"=>["admin", "sudonopw"], "locked"=>false,
> "comment"=>"System Operator", "uid"=>"700", "sshkeys"=>["ssh-rsa
> AAAAB3NzaC1yc2EAAAABIwAAAQEAwLBhQefRiXHSbVNZYKu2o8VWJjZJ/B4LqICXuxhiiNSCmL8j+5zE/VLPIMeDqNQt8L"],
> "gid"=>"700"}, "user2"=>{"groups"=>["admin", "sudonopw"], "locked"=>true,
> "comment"=>"Test Locked Account", "uid"=>"701", "sshkeys"=>["ssh-rsa
> AAAAB3NzaC1yc2EAAAABIwAAAQEAwLBhQefRiXHSbVNZYKu2o8VWJjZJ/B4LqICXuxhiiNSCm"],
> "gid"=>"701"}}
>
> My question is how I can get value of os_users -> user1 -> sshkeys. I tried:
> #hiera -c /etc/hiera.yaml os_users[user1[sshkeys]]
> nil
>
> Could you please advise whether this is doable or direct me to some document?
>
> Thanks in advance,
>
> carl
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/puppet-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/puppet-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/puppet-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.