Re: [Puppet Users] Noob question about the ${name} variable
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} Thanks and Regards, Rahul Khengare -- 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.
Re: [Puppet Users] Noob question about the ${name} variable
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.
[Puppet Users] Noob question about the ${name} variable
Greetings. When defining a file resource, why does the ${name} variable sometimes expand to the filename being maintained, and sometimes to the module name? Examples (in a module which, for simplicity, we will call apache) ... file { '/etc/httpd/conf/httpd.conf' : ensure = file , source = puppet:///modules/${module_name}${name} , } Here $name expands to /etc/httpd/conf/httpd.conf, so source expands to puppet:///modules/apache/etc/httpd/conf/httpd.conf. file { '/etc/httpd/conf.d/ssl.conf' : ensure = file , content = template ( ${module_name}{$name}.erb ) , } Here $name expands to apache, so the filename passed to template() is apacheapache.erb, rather than the expected and desired value apache/etc/httpd/conf.d/ssl.conf.erb. Why does $name expand differently in these cases, and where did I miss this in the documentation? -- 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.
Re: [Puppet Users] Noob question about the ${name} variable
On Sep 25, 2013, at 8:12 AM, John Simpson j...@voalte.com wrote: file { '/etc/httpd/conf.d/ssl.conf' : ensure = file , content = template ( ${module_name}{$name}.erb ) , } Here $name expands to apache, so the filename passed to template() is apacheapache.erb, rather than the expected and desired value apache/etc/httpd/conf.d/ssl.conf.erb. Is this the literal syntax? Because you have {$name} instead of ${name}. I can't explain why the former would expand the way it does, unless the braces around the variable name have special meaning. I would expect you'd get the literal braces in the expanded value. Not a real answer, but it does look unintentional. -- Brian Lalor bla...@bravo5.org http://github.com/blalor -- 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.
Re: [Puppet Users] Noob question about the ${name} variable
On 2013-09-25, at 0819, Brian Lalor bla...@bravo5.org wrote: On Sep 25, 2013, at 8:12 AM, John Simpson j...@voalte.com wrote: file { '/etc/httpd/conf.d/ssl.conf' : ensure = file , content = template ( ${module_name}{$name}.erb ) , } Here $name expands to apache, so the filename passed to template() is apacheapache.erb, rather than the expected and desired value apache/etc/httpd/conf.d/ssl.conf.erb. Is this the literal syntax? Because you have {$name} instead of ${name}. I can't explain why the former would expand the way it does, unless the braces around the variable name have special meaning. I would expect you'd get the literal braces in the expanded value. Not a real answer, but it does look unintentional. Sorry, I tried to remove a bunch of extraneous detail from my first message and fat-fingered the variable. The actual syntax, copied and pasted from the module, is: 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'] , } When I try to apply this on my test machine, I get... # puppet agent -t Info: Retrieving plugin Info: Loading facts in /var/lib/puppet/lib/facter/os_maj_version.rb Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find template 'apacheapache.erb' at /home/jms1/puppet/apache/manifests/init.pp:21 on node xxx Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run -- 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.