On 14 July 2012 01:22, Nick Fagerlund <nick.fagerl...@puppetlabs.com> wrote: > You may be doing something weird, because $name and $title inside a defined > type definition should definitely still refer to the instance's title. In > fact, I just tested it to be sure: > > define my_file ($message) { > notify {$title: > message => "$message, and the title is still $title", > } > } > > class my_class { > my_file {'the title of the resource, not the class': > message => "This is the message", > } > } > > include my_class > > ...should get you: > > notice: This is the message, and the title is still the title of the > resource, not the class > notice: /Stage[main]/My_class/My_file[the title of the resource, not the > class]/Notify[the title of the resource, not the class]/message: defined > 'message' as 'This is the message, and the title is still the title of the > resource, not the class' > notice: Finished catalog run in 0.05 seconds > > Show us what you're doing, maybe? >
I think the original poster referred to being able to access the title of a resource inside a resource definition (not a defined type). For example: class example { file { '/tmp/testfile': content => "foo ${name} bar\n", } Here $name would refer to "example", but he wants to access the name '/tmp/testfile'. But as the resource definition doesn't create a new scope there's no new variables in it. -- Erik Dalén -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.