Hi all!I've run into a problem, when I was trying to implement an lwrp, that does something like the artifact_package resource in https://github.com/RiotGames/artifact-cookbookThe simplified base of the lwrp looks like:use_inline_resourcesaction :installcustom_artifact_download_lwrp ...package ...endI wanted to test its idempotency, to make sure no notification will be propagated when the package is already installed. If any of the inner resources inside the custom_artifact_download_lwrp resource was modified (the file has been removed from the cache - we want to do periodic cleanup there) the notification was sent out even if the package was already installed. I wanted to force "mute" it somehow, because I want to avoid restarting services needlessly. I've naively tried:c = custom_artifact_download_lwrpc.updated_by_last_action(false)But after digging into the code I've realised I can not do this, since this code runs before the resource collection is converged. So if a resource gets modified the updated flag will be true and I cannot do anything about it. Is there a way to do this?Anyways, after reading the lwrp docs more closely, I've realized that I should do a conditional before declaring any of my resources, so ended up in doing this:def skip_install?(name, version)status = `dpkg -s #{name}`status.lines.any? { |l| /^Status: install ok installed/.match l } &&status.lines.any? { |l| /^Version: #{version}$/.match l }endaction :installunless skip_install?()custom_artifact_download_lwrp ...package ...endendI'm wondering if there is a more appropriate way of checking package availability, and wheter I've ended up doing this right or missing something?Thanks,pepov
Archive powered by MHonArc 2.6.16.