Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems

Puppet: recursively delete a Windows Registry key

Posted by Admin • Wednesday, October 14. 2015 • Category: DevOps

Puppet forge has a registry provider that allows one to manage a key or value. What it cannot do is delete a whole tree starting at a particular key. So, hacks to the rescue:


  # deletes the whole tree if it exists
  define registry_wipe_tree($key = $title) {
    exec {"Purge registry $key":
      path => ['c:/windows/system32'],
      command => "reg DELETE \"${key}\" /f",
      onlyif => "reg QUERY \"${key}\"",
    }
  }
 


Now if you want to, say, disable Java auto-update:

registry_wipe_tree{'HKLM\SOFTWARE\JavaSoft\Java Update':}
registry_wipe_tree{'HKLM\SOFTWARE\Wow6432Node\JavaSoft\Java Update': }
 

0 Trackbacks

  1. No Trackbacks

0 Comments

Display comments as (Linear | Threaded)
  1. No comments

Add Comment


You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
Markdown format allowed


Submitted comments will be subject to moderation before being displayed.