Pete Emerson
2009-Jul-08 22:46 UTC
[Puppet Users] Recursively templating files in a directory
Suppose I have 100 files distributed recursively: file { "/var/sample": source => "puppet:///files/sample", ensure => directory, recurse => true } What I''d like to do is have all files inside the directory be templated: file { "/var/sample": content => template("/var/lib/puppet/files/sample"), ensure => directory, recurse => true } This attempt doesn''t work (I''m running 0.24), and I don''t want to specify 100 separate file definitions in my manifest. What''s the right approach to recursively templating files? Thanks, Pete --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
David Schmitt
2009-Jul-09 19:18 UTC
[Puppet Users] Re: Recursively templating files in a directory
Pete Emerson wrote:> Suppose I have 100 files distributed recursively: > > file { "/var/sample": > source => "puppet:///files/sample", > ensure => directory, > recurse => true > } > > What I''d like to do is have all files inside the directory be templated: > > file { "/var/sample": > content => template("/var/lib/puppet/files/sample"), > ensure => directory, > recurse => true > } > > This attempt doesn''t work (I''m running 0.24), and I don''t want to > specify 100 separate file definitions in my manifest. What''s the right > approach to recursively templating files?The simplest approach would be a define: define templated_sample() { file { "/var/sample/${name}": content => template("sample/${name}"); } } and use an array: templated_sample{["file1","file2","dir/file3"]:} Since functions are evaluated on the server, you can create the array programatically from the list of templates: $files = split("\0", generate("find", "/var/lib/puppet/files/sample", "-type", "f", "-print0")) You''d need another define+array for the directories. But that''s just more of the same... Regards, DavidS --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Possibly Parallel Threads
- [RFC] IRBuilder polymorphism: Templates/virtual
- Is it possible to clone an NT ACL from one file or dir to a totally different file or dir ?
- templating language questions
- Managing directories recursively and adjust subdirectories permissions?
- patch to enable faster mirroring of large filesystems