Chef cookbook lwrp, the easiest way to use new_resource.updated_by_last_action (true)

I am writing LWRP for chef 10. And when this resource runs in other recipes, it should be marked as "updated_by_last_action" if something has changed. But if nothing has changed. updated_by_last_action must be false.

So, as an example, I have the chef documentation http://docs.opscode.com/lwrp_custom_provider.html#updated-by-last-action . In this example, the resource template is wrapped inside a variable to check if it has been changed, and then set the status to updated_by_last_action. So my code should look something like this.

f = file new_resource.filename do
xxx
end
new_resource.updated_by_last_action(f.updated_by_last_action?)

t = template new_resource.templatename do
xxx
end
new_resource.updated_by_last_action(t.updated_by_last_action?)

m mount new_resource.mountpoint do
xxx
end
new_resource.updated_by_last_action(m.updated_by_last_action?)

, , , , .. , , , , , .

, new_resource.updated_by_last_action(true) , . , new_resource.updated_by_last_action(true) action end, LWRP -, .

+3
1

use_inline_resources LWRP, updated_by_last_action .

+5

All Articles