Defined Type: registry::value

Defined in:
manifests/value.pp

Summary

High level abstraction on top of registry_key and registry_value resources

Overview

Actions:

- Manage the parent key if not already managed.
- Manage the value

Requires:

- Registry Module
- Stdlib Module
Note:

This defined resource type provides a higher level of abstraction on top of the registry_key and registry_value resources. Using this defined resource type, you do not need to explicitly manage the parent key for a particular value. Puppet will automatically manage the parent key for you.

Examples:

This example will automatically manage the key. It will also create a value named ‘puppetserver’ inside this key.

class myapp {
  registry::value { 'puppetserver':
    key => 'HKLM\Software\Vendor\PuppetLabs',
    data => 'puppet.puppetlabs.com',
  }
}

Parameters:

  • key (Pattern[/^\w+/])

    The path of key the value will placed inside.

  • value (Optional[String]) (defaults to: undef)

    The name of the registry value to manage. This will be copied from the resource title if not specified. The special value of ‘(default)’ may be used to manage the default value of the key.

  • type (Pattern[/^\w+/]) (defaults to: 'string')

    The type the registry value. Defaults to ‘string’. See the output of ‘puppet describe registry_value` for a list of supported types in the “type” parameter.

  • data (Optional[Variant[ String, Numeric, Array[String] ]]) (defaults to: undef)

    The data to place inside the registry value.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'manifests/value.pp', line 39

define registry::value (
  Pattern[/^\w+/] $key,
  Optional[String] $value   = undef,
  Pattern[/^\w+/] $type     = 'string',
  Optional[Variant[
      String,
      Numeric,
      Array[String]
  ]] $data                  = undef,
) {
  # ensure windows os
  if $facts['os']['name'] != 'windows' {
    fail("Unsupported OS ${facts['os']['name']}")
  }

  $value_real = $value ? {
    undef       => $name,
    '(default)' => '',
    default     => $value,
  }

  # Resource defaults.
  Registry_key { ensure => present }
  Registry_value { ensure => present }

  if !defined(Registry_key[$key]) {
    registry_key { $key: }
  }

  # If value_real is an empty string then the default value of the key will be
  # managed.  Use a double backslash so value names with a backslash are supported
  registry_value { "${key}\\\\${value_real}":
    type => $type,
    data => $data,
  }
}