I think that I am almost at the understanding that I need in regards to LWRPs and notifications and use_inline_resources - I just want to verify that I truly get this subject given what I think is it's importance and the somewhat fuzzy docs that seems to exist around it.I write a good number of LWRPs and originally used the below general paradigm as I learned from the customizing chef o'reilly book.def whyrun_supported?trueendaction :create do_user = new_resource.user ? new_resource.user : "root"_group = new_resource.group ? new_resource.group : "root"directory ::File.dirname(new_resource.name) doowner _usergroup _groupmode "0700"action :createrecursive trueendnew_resource.updated_by_last_action(true)endI realized soon that there is a a serious flaw to this original paradigm which is that by specifying new_resource.updated_by_last_action(true) this resource always thinks that it does something and if I happen to perform any notification based on it - they will always fire. (Took a a bit of time to figure out why a service was restarting on every Chef run)I use Chef 11 all around so I realized that I could change my overall paradigm todef whyrun_supported?trueenduse_inline_resourcesaction :create do_user = new_resource.user ? new_resource.user : "root"_group = new_resource.group ? new_resource.group : "root"directory ::File.dirname(new_resource.name) doowner _usergroup _groupmode "0700"action :createrecursive trueendendNow I get the behavior that I want which is that when the underlying resource actually triggers then the LWRP will send notifies rather than all the time. I realize that the use of use_inline_resources means that I can only notify other resources within my LWRP - but that is fine by me.MY FIRST REAL QUESTION: If I happen to only use already existing resources in my then I never have call new_resource.updated_by_last_action(true). Is this accurate?SECOND QUESTION: If I need to call new_resource.updated_by_last_action(true) because I do something outside and existing resource -- can I mix use_inline_resources and new_resource.updated_by_last_action(true) in the same provider?THIRD QUESTION: I have seen the below code which I know is "old" but I think should work but does not seem to work. Is this paradigm now longer valid? Even when the resource creates the directory it seems that d.updated_by_last_action? always evaluates to falsedef whyrun_supported?trueendaction :create do_user = new_resource.user ? new_resource.user : "root"_group = new_resource.group ? new_resource.group : "root"d = directory ::File.dirname(new_resource.name) doowner _usergroup _groupmode "0700"action :createrecursive trueendnew_resource.updated_by_last_action(d.updated_by_last_action?)endThanks for listening.
Archive powered by MHonArc 2.6.16.