end up I just use a simple array to solve the issue: Examples <https://docs.puppetlabs.com/puppet/latest/reference/lang_iteration.html#examples>Declaring Resources <https://docs.puppetlabs.com/puppet/latest/reference/lang_iteration.html#declaring-resources>
Since the focus of the Puppet language is declaring resources, most people will want to use iteration to declare many similar resources at once: $binaries = ["cfacter", "facter", "hiera", "mco", "puppet", "puppetserver"] # function call with lambda:$binaries.each |String $binary| { file {"/usr/bin/$binary": ensure => link, target => "/opt/puppetlabs/bin/$binary", }} On Tuesday, October 20, 2015 at 5:23:13 PM UTC-7, yi zhao wrote: > > Hi, > so we have a few template setup under my_module/templates/ > like > create_pre_rac_setup.sh.erb > run_this_rac.sh.erb > .... > > > and I write someting in init.pp > > $db_setup_home = "$dbnamehome/dbs/create_$dbname" > file { "$db_setup_home/create_pre_rac_setup_$dbname.sh": > ensure => 'file', > content => template("${module_name}/create_pre_rac_setup.sh.erb"), > mode => '0644', > owner => 1001, > group => 1000, > } > > file { "$db_setup_home/run_this_rac_$dbname.sh": > ensure => 'file', > content => template("${module_name}/run_this_rac.sh.erb"), > mode => '0644', > owner => 1001, > group => 1000, > } > > but if I have 500 templates, I would have to write 500 files which is > against puppet thinking, is there a way to write a loop to read all > template files under my_module/templates/ > then just loop to create the files with the same naming standard? > > > thank you. > > > -- 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/a69a1e07-ca45-4b1d-bff3-fbb1ffeb6313%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.