So I was in need to update a registry value of the type binary with puppet. I faced two issues:

  1. I had no intention of copying the binary data by hand.
  2. I had no clue with the format of the data for puppet.

Lets start with the first. Lets get the data from the registry of another machine. I am used to using running things in Powershell, So I’ll do it that way.

I just used Get-ItemProperty to get the value from the registry and then do some reconstruction of the data as octects with spaces between.

PS C:\Users\virot> [string]::join(' ',((Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\SplunkForwarder" -Name FailureActions).FailureActions|ForEach{'{0:x2}' -f $_}))
80 51 01 00 00 00 00 00 00 00 00 00 03 00 00 00 14 00 00 00 01 00 00 00 c0 d4 01 00 01 00 00 00 c0 d4 01 00 01 00 00 00 c0 d4 01 00

So how do we use this with puppet? I read the source for the registry module and found out that I was supposed to send the data in as a string with spaces between the octects. To be honest I first tried an array, that failed. Then I tried to read the source. So this is a small snippet that will update the registry then notify the service, which will restart it.

	registry_value { 'HKLM\SYSTEM\CurrentControlSet\Services\SplunkForwarder\FailureActions':
		ensure => present,
                type   => binary,
                data   => '80 51 01 00 00 00 00 00 00 00 00 00 03 00 00 00 14 00 00 00 01 00 00 00 c0 d4 01 00 01 00 00 00 c0 d4 01 00 01 00 00 00 c0 d4 01 00',
		before => Service['SplunkForwarder'],
		notify => Service['SplunkForwarder']
        }