Created
May 13, 2017 04:12
-
-
Save purplexa/014fa9eaebf58022a10e787b22904fa9 to your computer and use it in GitHub Desktop.
metaparameters on hiera-defined resources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class foobar ( | |
Hash[String, | |
Struct[{ | |
attributes => Hash[String, Data], | |
Optional[requires] => Hash[String, String], | |
Optional[notifies] => Hash[String, String] | |
}]] $files, | |
Hash[String, Data] $file_defaults = {}, | |
) { | |
$files.each |$key, $value| { | |
$requires = $value['requires'].reduce([]) |$memo, $x| { $memo + [Resource[$x[0]][$x[1]]] } | |
$notifies = $value['notifies'].reduce([]) |$memo, $x| { $memo + [Resource[$x[0]][$x[1]]] } | |
file { | |
$key: | |
* => $value['attributes'], | |
require => $requires, | |
notify => $notifies, | |
; | |
default: | |
* => $file_defaults, | |
; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
foobar::files: | |
'/etc/foo': | |
attributes: | |
ensure: 'file' | |
owner: 'root' | |
group: 'root' | |
mode: '0640' | |
requires: | |
package: 'foo' | |
notifies: | |
service: 'foo' | |
'/etc/bar': | |
attributes: | |
ensure: 'directory' | |
owner: 'bar' | |
group: 'bar' | |
mode: '0750' | |
'/etc/bar/bar.conf': | |
attributes: | |
ensure: 'file' | |
owner: 'bar' | |
group: 'bar' | |
mode: '0640' | |
requires: | |
package: 'bar' | |
notifies: | |
service: 'bar' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment