Should Package always return a 1 even if it doesn't need to install?


#1

I’ve noticed a particular behavior when using both Package and Windows_Package that I’m curious about.

Even with a very basic recipe, it seems that on the first run of a recipe it installs the required ‘source’ fine. However on subsequent runs it still tries to do the install and responds with a ‘1/1’ updated at the end. In subsequent runs it doesn’t need to install so why does it it think it does? Or am I misinterpreting the response code? My concern is that if I add a notify, for example to reboot after an install, and it responds with a 1, it will re-boot even if not necessary.

Perhaps I’m missing something about how Chef works ( not been using it for too long) so I’d love to know more about what is happening in this instance. Any help is much appreciated.

I’ve done a bit more testing and it seems that this is particular to installing a .exe file. Installing a .msi works fine. I assume that it is therefore related to how to the underlying installer works and how it responds back that drives Chef’s response code.


#2

Ideally a package should not converge on every client run. This is most likely happening because on subsequent runs, the package resource does not have the information it needs to be able to locate the package on the system and therefore thinks it needs to reconverge every time. This can easily happen particularly with .exe based installers as opposed to .msis.

To avoid this you want to make sure your package name is exactly the same as how it reads in the “Add or Remove Programs” windows GUI. The package resource on windows needs to find the corresponding registry information for the package you are installing, using .msis, there is a straight forward API for doing this but not so for .exes. If you rename the resource to match the “Add or Remove Programs” name, it should not reconverge on subsequent chef runs.