you are right again:-) For people who are new to puppet, here is the installation instruction - http://forge.puppetlabs.com/puppetlabs/stdlib. stdlib is built in Puppet Enterprise and needs to be installed for community version.
cheers, carl On Tuesday, February 5, 2013 11:28:46 AM UTC-5, Steven wrote: > > keys comes form the PuppetLab's stdlib module > So does is_array and a bunch of other nice functions > > > Steven > > > ------------------------------ > Date: Tue, 5 Feb 2013 07:12:45 -0800 > From: [email protected] <javascript:> > To: [email protected] <javascript:> > Subject: Re: [Puppet Users] hiera query yaml parameters > > Steven, thanks for your reply! You are right. It is unnecessary using > create_resource to query yaml parameters. It can be done directly as > following: > > $sshd_hash = hiera(os_users) > $server_ssh_keys = $sshd_hash[$username][ssh_keys][key] > > format of my os_users yaml file was not correct, that is why it failed me. > > Btw, there is no keys function in puppet. > > Cheers, > > carl > > > > On Sunday, February 3, 2013 10:21:25 PM UTC-5, Steven 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] <javascript:>. > To post to this group, send email to [email protected]<javascript:> > . > 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.
