On 2013-09-26, at 0303, Rahul Khengare <rahulk1...@gmail.com> wrote: > Hi John, > Read my previous reply, > > file { '/etc/httpd/conf.d/ssl.conf' : > ensure => file , > mode => 0644 , > owner => 0 , > group => 0 , > content => template ( "${module_name}${name}.erb" ) , > notify => Service['httpd'] , > require => Package['httpd'] , > } > > The '/' is missing in between ${module_name} and ${name}
Sorry, but I wrote the line this way specifically because the first character of the value of $name is "/". Adding an extra "/" between "${module_name}" and "${name}" would result in "apache//xxx.erb". Presumably the "//" wouldn't hurt anything (the Linux kernel ignores the empty directory element between the two slashes when resolving the filename), but it wouldn't have helped either. I did, however, figure out what the problem was. In this case, it was confusion caused by either less-than-perfect documentation, or my own less-than-perfect understanding of that documentation. The confusion has to do with what the $name variable actually is. Essentially, it does not refer to the item you're declaring (in this case, a file.) It refers to the object WITHIN WHICH you are declaring it. So for a file declared within a class... class apache { file { 'blah' : ensure => file , content => template ( "${module_name}${name}.erb" ) , } } the value of $name is "apache" (the name of the class.) And for a file declared within a define... class apache { define configfile { file { $name : ensure => file , content => template ( "${module_name}${name}.erb" ) , } } configfile { '/etc/httpd/conf.d/01_aaa.conf' : } configfile { '/etc/httpd/conf.d/02_bbb.conf' : } } the value of $name, in both locations, is the value with which that "define" is later instantiated. So in the second example, $name would be either "/etc/httpd/conf.d/01_aaa.conf" or "/etc/httpd/conf.d/02_bbb.conf", depending on which "configfile" object is being instantiated at the time. The real problem I was trying to solve is that I didn't want to have to type each filename twice, primarily because it opens up a potential source of errors if the names aren't typed exactly the same. Creating a "wrapper" around the file object allows the same name to be used multiple times, without having to worry about the name potentially not being identical. It also allowed me to include several other elements (such as "owner", "mode", and "notify") which would otherwise have had to be duplicated. My thanks to everybody who offered advice. -- John Simpson <j...@voalte.com> Unix System/VM Developer and Engineering Operations, Voalte +1 (941) 312-2830 x148 -- 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 post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.