Issue #15718 has been updated by eric sorenson. Status changed from Unreviewed to Duplicate
Thanks Rémy, I agree -- this is a duplicate of an old bug that deserves attention: #5259 ---------------------------------------- Feature #15718: $name var should be resource name systematicaly https://projects.puppetlabs.com/issues/15718#change-69281 Author: Rémy Garrigue Status: Duplicate Priority: Normal Assignee: Category: Target version: Affected Puppet version: Keywords: name title var class resource Branch: Here is an extract of the documentation: Defined types have a number of built-in variables available, including $name and $title, which are set to the title of the resource when it is declared. (The reasons for having two identical variables with this information are outside the scope of this document, and these two special variables cannot be used the same way in classes or other resources.) As of Puppet 2.6.5, the $name and $title variables can also be used as default values for parameters This is very nice. But the fact that it's not the case for something else than defined resource is counter intuitive. For example, I tried <pre>file { ["test1","test2"]: ensure => present, content => "test", path => "/tmp/$name", }</pre> That doesnt work, because $name is replaced by 'main', the class's name containing this test: <pre>Cannot alias File[test2] to ["/tmp"] at /home/rgarrigu/xtreemOS/vagrant/manifests/xtreemos-devel.pp:25; resource ["File", "/tmp"] already defined at /home/rgarrigu/xtreemOS/vagrant/manifests/xtreemos-devel.pp:25</pre> I had to do this to get it to work: <pre>define myfile { file { $name: ensure => present, content => "test", path => "/tmp/$name", } } myfile { ["test1","test2"]: }</pre> Agreed, the workaround is not that hard or ugly. But imho $name/title behing defined as the first container name would be far more intuitive. -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
