puppet- on windows common issues – 1

By W.ZH Sept 2013

Puppet has strong feature for Linux/Unix, but not very strong in windows. You should read the doc for windows when you plan to use to control the windows client.

Puppet on Windows
http://docs.puppetlabs.com/windows/index.html

Here I summarize some valuable common experience on windows I met.

About windows MSI and exe installer

puppet can control the msi program by wmic for you, this means, you just need to use the package to control a program is installed or not.

class dotnet_4_5 {
package { ‘Microsoft .NET Framework 4.5’:
ensure => installed,
source => “E:\\MYLocationFor4.5.netframwork installer\\\dotnetfx45_full_x86_x64.exe”,
install_options => [ ‘/quiet’ ,’/norestart’],
}
}

Here the package name must be same with the name in the MSI system. Source is point to the MSI installer for the program. By this case, puppet will go to your system detect by MSI to see whether
Microsoft .NET Framework 4.5 is installed or not, is installed, it will do nothing, if not, it will use source to install it.

 

But you know that there are many install can not be done by MSI, such as you want to install the SOAPUI. it use other installer to install. so exec will be very common to use for windows to do some install or script job for you.
class soapui {
$installerfile = ‘C:/TEMP/soapUI-x64-4.5.2.exe’
$targetInstalledEXEfile = ‘C:/Program Files/SmartBear/soapUI-4.5.2/bin/soapUI-4.5.2.exe’

################################################################################
# 2. to detect that SOAPUI is installed or not in target windows, by check some files existing or not
#     the reason is because the puppet can not auto find the soapui installed or not,
#   it will try to auto install every time
# 3. if there is not installed, then we can make a silent install for soap UI.
#     use default location and default config, this version should be a free version

# Run installer command unless target file exists
exec { ‘install_the_soapui_4_5_2’:
command => “$installerfile -q -splash title”,
creates => $targetInstalledEXEfile,
provider => windows,

timeout =>60,
# as we use “creates”, so we do not need onlyif anymore,
# onlyif => “if exist \”$targetInstalledEXEfile\” exit 1 else exit 0″
}
}

How to list the MSI installed products in your windows,

wmic product

Yes, that is all. It runs for a while and then spits out very detailed information on what is installed on the local system. If you need the information in a file for later processing, use the following variation of above command to have wmic create a CSV file:

wmic product get /format:csv > C:\TEMP\Software_MyPC.csv

about the MSI, exe refer to here:
http://www.symantec.com/connect/articles/understanding-difference-between-exe-and-msi

http://www.sepago.de/d/helge/2010/01/14/how-to-list-all-installed-applications-from-the-command-line

 

Advertisements