Search code examples
windowsautomationregistryinstallationpuppet

Telling Puppet to only run an install if registry key is not present


I have written manifest that installs an .exe and applies a hotfix to it every-time it installs on a new machine.

windowsinstaller { 'AppFabric install 1.1 install':     
  software_title  => 'AppFabric 1.1 for Windows Server',
  software_path   => '/Microsoft/AppFabric1.1/WindowsServerAppFabricSetup_x64.exe',
  install_options => ['/i','/SkipUpdates'],
}

windowsinstaller { 'AppFabric 1.1 HotFix install':  
  software_title  => 'Windows Server AppFabric v1.1 CU5 [KB2932678]',   
  software_path   => '/Microsoft/AppFabric1.1/AppFabric1.1-KB2932678-x64-ENU.exe',
  install_options => ['/q','/norestart'],   
  subscribe => Windowsinstaller['AppFabric install 1.1 install']
}

service { 'Remote Registry Service':
  name    => 'RemoteRegistry',
  ensure  => running,
  restart => true,
} 

I am trying to get this install to run only if it's registry key is absent.

Using puppetlabs registry module you can manage keys, redirect them, and change the values.

reference: http://puppetlabs.com/blog/module-of-the-week-puppetlabs-registry-windows

Unfortunately, I can't seem to find a way to simply check if the key is there, I can either delete it or make sure its present using ensure => present and ensure => absent.

As I can't put resources into variables I am finding it hard to use conditional statements, and as present and absent set the key instead of check it, I don't think I can use meta parameters with the registry_key resource.

I know that I can wrap everything in an if statement and use a custom fact but I have been told that this is not the right way to proceed.

If anyone has an example of where this has been done before either using this module or something else registered in the puppet forge or any ideas it would be greatly appreciated.


Solution

  • The user manbart found the answer 7 months ago with this question

    Exec onlyif registry value is not present

    calling reg.exe to query the registry in an exec resource.