On 04/05/17 09:26, Quentin lenglet wrote:
Ho everyone,I have a lot of difficulty on Puppet for writing my own module and I don't succeed to understand how the module are made on Internet. I need to develop a custom module for put ssh keys into the right file. My ideas is to put an array with the SSH keys and write the key in the file with an iterative way. But i don't find any clear method to do that. Can you help me ? This is my code: # == Class: lpsc::config class lpsc::config inherits lpsc { file { '/etc/ssh/sshd_config': ensure => present, owner => 'root', group => 'root', mode => '0600', } if ($lpsc::ssh_keys == undef) { notify{"Pas de clef à rajouter":} } else { notify{"On peut rajouter une clef ${lpsc::ssh_keys}":} $demofiles = "/root/.ssh/test" $lpsc::ssh_keys.each | String $value | { file {$demofiles: ensure => present, replace => 'yes', owner => 'root', group => 'root', mode => '0600', content => $value, } } } }
You logic creates one file for each ssh_key - it will not work since your are telling the agent to ensure that the very same file has different content.
You need on file resource and you want the content to be the list of keys in text form. The easiest is probably to use the "join" function in stdlib. Join with a ',' or ' ' depending on what you want as separator in your file.
Hope that helps, - henrik
Thx for your help Have a good day! Quentin Lenglet -- 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] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/182731ab-a16b-4002-a3c7-48671035f630%40googlegroups.com <https://groups.google.com/d/msgid/puppet-users/182731ab-a16b-4002-a3c7-48671035f630%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout.
-- Visit my Blog "Puppet on the Edge" http://puppet-on-the-edge.blogspot.se/ -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/oei07l%24vaa%241%40blaine.gmane.org. For more options, visit https://groups.google.com/d/optout.
