I am trying to understand how Chef on Windows but also unix, checks whether applications and packages specified in the cookbook are installed so it can skip any resource blocks in the recipe rather than attempt to just re-install over the top of an existing app or package. I see 3 scenarios for Windows according to the docs:
1. The source property is supplied with a value:
The docs for "package" or "windows_package" resources say that the "source" property if used should point to a package on the file system or URL. Is it looking for the exact file name installer executable with file extension or without?
package 'adobereader' do
source C:\path\to\my\installer_file\adobereader.exe
end
windows_package 'adobereader' do
source C:\path\to\my\installer_file\adobereader.exe
end
I don't see how this indicates installed vs not, but can see that it might be checking behind the scenes if the file exists.
2. Source property is NOT provided:
If the "source" property is not provided in the resource block, Chef uses the resource block name to associate with a file or URL. Filename with or without extension?
package 'adobereader' do
end
windows_package 'adobereader' do
end
I don't see how this indicates installed vs not either, but can see that it might be checking behind the scenes if the file exists.
3. Resource block name, or "package_name" property matches DisplayName value in registry:
If no source property is provided, the display name of the resource block or a provided "package_name" property, instead of pointing to a installer filename on the file system or a URL, it should point to the DisplayName value matching an entry in any of the following registry hives:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
package 'Adobe Reader DC' do
package_name 'Adobe Reader DC'
end
windows_package 'Adobe Reader DC' do
package_name 'Adobe Reader DC'
end
If Chef does not find a file at the location or URL, does it automatically check the registry?
Checking the registry for this DisplayName does validate whether something is installed but ONLY IF the program registers it there. A lot of pre-req utilities and smaller apps/tools, don't publish there.
Further Questions:
-
Are cookbook authors supposed to use notifies, guards, or script resources to do custom checks for whether software is installed?
-
What about windows_features? Docs say nothing about whether the resource block name is checked against existing enabled DISM values. In addition DISM values differ from the Server Mgr GUI display name, for instance 'HTTPS Errors' is the name of the check box in the GUI and the DISM value is 'IIS-HttpErrors'. Both DISM and powershell cmdlets use the DISM values.
But the real question I have is it checking to see if it is installed or enabled? IF NOT, how does it not just re-install the feature and overwrite? If it is checking, shouldn't this be noted in the docs or listed somewhere with all the other resources that do that?
-
What about package and the unix package managers, how does Chef work with them to validate installed or not before converging and re-installing or overwriting?
-
Are there any other resources that function like windows_package to use the registry or some other source of installation validation? Or are all required to have custom guards, notifies, that have logic to check based on the author's knowledge of how to tell the app is installed?
-
Where does the Ohai data get factored into the check? It does not contain installed information outside of the package attribute which is essentially the unistall registry DisplayName items.
-
Is there some sort of mapping or cross reference chart that lists resources and the system item used to verify application installations or whether Chef should skip the resource in a cookbook every time the client runs?