Last active
December 16, 2015 13:28
-
-
Save ripienaar/59018d7c084059e776f2 to your computer and use it in GitHub Desktop.
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
create_resources("mail::domain", $domains) |
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
{ | |
"relay_domains": { | |
"x.net": { | |
"nexthop": "70.x.x.x", | |
"spamdestination": "[email protected]", | |
"spamthreshold": 1500, | |
"enable_antispam": 1 | |
}, | |
"x.co.uk": { | |
"nexthop": "70.x.x.x", | |
"spamdestination": "[email protected]", | |
"spamthreshold": 1500, | |
"enable_antispam": 1 | |
}, | |
} |
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
$names = keys($domains) | |
mail::domains($names: domains => $domains} | |
define mail::domains($domains) { | |
$domain = $domains[$name] | |
mail::domain{$name: | |
nexthop => $domain["nexthop"] | |
. | |
. | |
} | |
} |
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
$domains.each |$name, $domain| { | |
mail::domain{$name: | |
nexthop => $domain["nexthop"] | |
. | |
. | |
} | |
} |
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
each($domains) |$name, $domain| { | |
# see https://docs.puppetlabs.com/puppet/4.2/reference/lang_resources_advanced.html#setting-attributes-from-a-hash | |
mail::domain{$name: | |
* => $domain | |
} | |
} |
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
$defaults = { | |
"spamthreshold" => 1500, | |
"enable_antispam" => 1 | |
} | |
$domains.each |$name, $domain| { | |
# see https://docs.puppetlabs.com/puppet/4.2/reference/lang_resources_advanced.html#setting-attributes-from-a-hash | |
mail::domain{$name: | |
* => $defaults + $domain # + now merge hashes | |
} | |
} |
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
$defaults = { | |
"spamthreshold" => 1500, | |
"enable_antispam" => 1 | |
} | |
$domains.each |$name, $domain| { | |
mail::domain{ | |
default: | |
* => $defaults; | |
$name: | |
* => $domain | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment