Resource Type: resource_value
- Defined in:
- lib/puppet/type/resource_value.rb
- Providers:
-
simple
Overview
The type allows you to specify individual properties of native Puppet types as resources in a Puppet catalog.
This can be usefull when you need to add specific properties to an exsiting resource, but need to do it somewhere else in your puppet code. Here is an contrived example:
file {'/etc/a.a':
ensure => 'present',
group => 'root',
}
and in some other manifest:
resource_value{ "File[/etc/a.a]owner":
value => 'vagrant'
}
here you add the ‘owner` property to the resource `File`. When you run this manifest, you will only see that the `File` beeing managed once and all properties beeing set to the correct value.
By default the ‘resource_value` doesn’t allow you to override the existing value. So this means when the value is already set somewhere in the catalog. So when we try this example:
file {'/etc/a.a':
ensure => 'present',
group => 'root',
owner => 'root'
}
resource_value{ "File[/etc/a.a]owner":
value => 'vagrant'
}
This happens:
Error: /Stage[main]/Main/Resource_value[File[/etc/a.a]owner]: Resource_value[File[/etc/a.a]owner]: Property owner value already defined on File[/etc/a.a] in catalog.
Error: Failed to apply catalog: Some pre-run checks failed
When you want to override this behavior check the ‘ allow_redefine` parameter.
By default the ‘resource_value` type uses an existing resource in the catalog. When you try to use `resource_value` without existing resource this happens:
Error: /Stage[main]/Main/Resource_value[File[/etc/a.a]owner]: Resource_value[File[/etc/a.a]owner]: resource 'File[/etc/a.a]' not found in catalog
Error: Failed to apply catalog: Some pre-run checks failed
When you want ‘resource_value` to create the resource, you have to set the `allow_create` property to true.
WARNING
The ‘resource_value` is a type that can be useful in specific cases. We have build it to support CIS benchmarks in Puppet. Our use case was to allow the manifest writer to “just do his thing” and us to add the extra security layer. Without knowing to much about each other. That said. Don’t over use this type. Specially the ‘add_value` and the `remove_value` override existing values without warning and searching for (logical) errors in your manifest becomes very difficult.