Created
May 9, 2013 17:59
-
-
Save danshultz/5549265 to your computer and use it in GitHub Desktop.
I'm using a custom ENC which we are using to dump a yaml file based on an internal configuration wrapper. I want the ability to specify a parameter (variable) in the top scope and allow it to be be a default variable of a class. At this point, my research shows me this is not a bad idea
This file contains hidden or 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
| classes: | |
| rsyslog::client: | |
| port: 1234 | |
| parameters: | |
| server: my-rsyslog-server |
This file contains hidden or 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
| # This patterns supports defaulting a class scoped variable to the first scope level variable it comes across. | |
| # If I wanted to explicitly check only the top level scope, I would do $::server | |
| class rsyslog::client( | |
| $server => $server, # $server = $server || undef | |
| $port => $port ? { # $port = $port || '514' | |
| '' => '514', | |
| default => $port | |
| } | |
| ) { | |
| if !defined($server) { fail "server must be defined" } | |
| notify { "The server is ${server}": } | |
| notify { "The port is ${port}": } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment