@Reid: Agreed it make sense to reference another resource instead of path string. The links you shared are very helpful. Thanks!!!
@Dylan: While going through defined types i came across vhost here: https://github.com/puppetlabs/puppetlabs-apache/blob/master/manifests/vhost.pp I am not very clear how can i use it in my case. If a new defined type is used say new_type::load as below will it work? # /etc/puppetlabs/puppet/modules/new_type/manifests/load.pp define new_type::load ($path, $template_path){ include new_type file { $path: content => template($template_path), notify => new_type[ ? ], ---------> *how to pass 'sample' here? * } } #/etc/puppetlabs/puppet/manifest/site.pp node 'node_name' { $names = [ "abc", "xyz" ] new_type::load {'sample': path => '/var/tmp/test.txt' template_path => 'new_type/test_template.erb', ensure => present } } #/etc/puppetlabs/puppet/modules/new_type/templates/test_template.erb <% @names.each do |name| %> Hi <%= name %>!!! <% end %> ~ On client run #cat /var/tmp/test.txt Hi abc!!! Hi xyz!!! new_type resource 'sample' should be notified every time contents of test.txt is modified. On Thu, Jun 18, 2015 at 3:48 AM, Dylan Ratcliffe < [email protected]> wrote: > Assuming that the "file" and the "new_type" resource will always be > together I would wrap them in a defined type and expose everything you need > as parameters. That way both can have access to it without any hacky stuff. > > I'm not sure of your level of Puppet knowledge so if that makes no sense > let me know and I will explain. > > > > On Thursday, 18 June 2015 02:16:11 UTC+10, Michael Smith wrote: >> >> There's probably a way to do that, but I don't think it's a good idea. >> >> In order to look at the 'path' attribute of the 'file' resource, you'd >> need to specify which 'file' resource your new_type relates to. That means >> new_type would have a property with the value File['interface'], which >> isn't much different than having the 'path' property. Unless your type is >> specifically operating on the File resource abstraction, rather than the >> physical file itself, using 'path' seems to make more sense. >> >> Overloading the notify/require relationship to make that association >> would be a bad idea - they're 1-to-many and many-to-1 relationships - and >> probably complicated to make work. >> >> On Wed, Jun 17, 2015 at 7:38 AM, ganesh634 <[email protected]> wrote: >> >>> Pasted below an example relation for new resource say 'new_type'. >>> >>> >>> >>> file >>> >>> { "interface": >>> >>> path => "/var/tmp/test.txt", >>> >>> content => template("module/test_template.erb"), >>> >>> notify => new_type['sample'], >>> >>> } >>> >>> new_type >>> >>> { "sample": >>> >>> path => "/var/tmp/test.txt", >>> >>> active =>true, >>> >>> ensure=>present, >>> >>> } >>> >>> >>> >>> In 'new_type' resource implementation I want to access value of 'path' >>> attribute value from 'file' resource to determine certain action in >>> 'new_type' resource. >>> >>> With current approach I have to keep ‘path’ attribute in ‘new_type’ and >>> mandate user to have ‘path’ value same as that of ‘path’ value in file >>> resource. >>> >>> >>> >>> How can I access 'file’ resource 'path' attribute value in 'new_type' >>> resource implementation? >>> If it is possible I can remove the 'path' attribute from 'new_type' >>> resource body as value of both path need to be same all the time. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Puppet Developers" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/puppet-dev/004da5f1-be9f-4352-a1f8-b43f34c2d859%40googlegroups.com >>> <https://groups.google.com/d/msgid/puppet-dev/004da5f1-be9f-4352-a1f8-b43f34c2d859%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Michael Smith >> Sr. Software Engineer, Puppet Labs >> >> *PuppetConf 2015 <http://2015.puppetconf.com/> is coming to Portland, >> Oregon! Join us October 5-9.* >> *Register now to take advantage of the Early Adopter discount >> <https://www.eventbrite.com/e/puppetconf-2015-october-5-9-tickets-13115894995?discount=EarlyAdopter> >> * >> *—**save $349!* >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Puppet Developers" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/puppet-dev/oBrN1RToyUI/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-dev/fb4e828e-0284-416d-8714-3b9314b47277%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-dev/fb4e828e-0284-416d-8714-3b9314b47277%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/CA%2B6y2sF%3DKv-MwcB87HcCk8jkbchct6bp4i3Ev%2B9huV3O6DnbRw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
