Defined Type: postfix::config
- Defined in:
- manifests/config.pp
Overview
Definition: postfix::config
Uses Augeas to add/alter/remove options in postfix main configuation file (/etc/postfix/main.cf).
TODO: make this a type with an Augeas and a postconf providers.
Parameters
- name
-
name of the parameter.
-
- ensure
-
present/absent/blank. defaults to present.
-
- value
-
value of the parameter.
-
Requires
Examples
postfix::config { 'smtp_use_tls':
ensure => 'present',
value => 'yes',
}
postfix::config { 'relayhost':
ensure => 'blank',
}
30 31 32 33 34 35 36 37 38 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 |
# File 'manifests/config.pp', line 30
define postfix::config (
Optional[String] $value = undef,
Enum['present', 'absent', 'blank'] $ensure = 'present',
) {
include postfix
if ($ensure == 'present') {
assert_type(Pattern[/^.+$/], $value) |$e, $a| {
fail "value for parameter: ${title} can not be empty if ensure = present"
}
}
if (!defined(Class['postfix'])) {
fail 'You must define class postfix before using postfix::config!'
}
case $ensure {
'present': {
$changes = "set ${name} '${value}'"
}
'absent': {
$changes = "rm ${name}"
}
'blank': {
$changes = "clear ${name}"
}
default: {
fail "Unknown value for ensure '${ensure}'"
}
}
augeas { "manage postfix '${title}'":
incl => "${postfix::confdir}/main.cf",
lens => 'Postfix_Main.lns',
changes => $changes,
require => File["${postfix::confdir}/main.cf"],
}
Postfix::Config[$title] ~> Class['postfix::service']
}
|