On Thu, May 07, 2015 at 08:50:12AM -0700, Mohan L wrote: > Dear All, > I am new to Puppet. Recently started l learning it. > I need to push multiple ssh keys for client machine, > Here is what I have written: > Hiera: > # cat hiera.yaml | grep -v ^# > --- > :backends: > - yaml > :hierarchy: > - global > :yaml: > :datadir: /etc/puppet/hieradata > > # cat /etc/puppet/hieradata/global.yaml > # hash with keys in the hiera structure. The hash is merged with > hiera_hash lookup > sshkeys::keys: > sg-vm-agent-004: > user: 'ubuntu' > type: 'ssh-rsa' > key: > > 'AAAAB3NzaC1yc2EAAAADAQABAAABAQDJzdGydf2tdZYCkBRGx/SnlVKW+9q3Mqtf9vCrs0SaSkwDK4Q36hS40IVgmri2mjKeWFr5p92OgYY1hjZk4LLUAbVV8ItmPLqvmfrkOEwDCzmkbrUVa4BTKePWG0hOGAVYSQkS+1vhsTFhtznJMxsjRVwj8tO3s0fSnaXcovs9d4LwXhRbcDjzrAVRkk2d5/lSbjc/T4ZJ6oMKcGCxq02etJMoSBBQsEfRP/vULqKjoxJ96kb3Y43tU7gRzcVkXAyNqpXie8fD/FopoVi/uHIqkzotkOwztUYNt6C5LwV/W4ds5x3Zl7Jo4kqup2FOCs4oXSC3WxJI5FJ9WuPMtK1r' > # cat site.pp > $keys_hash = hiera_hash('sshkeys::keys',undef) > $username=$keys_hash[$hostname]['user'] > sshkeys::key { "$hostname": > key_name => "$hostname", > user => "$username", > } > How to push multiply ssh keys to client?
For puppet <4, look into create_resources and defined types. https://docs.puppetlabs.com/puppet/3.7/reference/lang_defined_types.html http://docs.puppetlabs.com/references/3.stable/function.html#createresources For puppet 4, it's probably easier to loop over the hash keys. I haven't used this yet. https://docs.puppetlabs.com/puppet/latest/reference/future_lang_iteration.html > thanks for your time > > -- > 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 [1]puppet-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > > [2]https://groups.google.com/d/msgid/puppet-users/d9125204-7e05-472c-8029-1cb6f0a1c476%40googlegroups.com. > For more options, visit [3]https://groups.google.com/d/optout. > > References > > Visible links > 1. mailto:puppet-users+unsubscr...@googlegroups.com > 2. > https://groups.google.com/d/msgid/puppet-users/d9125204-7e05-472c-8029-1cb6f0a1c476%40googlegroups.com?utm_medium=email&utm_source=footer > 3. https://groups.google.com/d/optout -- 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 puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20150507172651.GA8304%40iniquitous.heresiarch.ca. For more options, visit https://groups.google.com/d/optout.