diff options
| author | Micah <micah@leap.se> | 2016-07-12 16:46:25 -0400 | 
|---|---|---|
| committer | Micah <micah@leap.se> | 2016-07-12 16:46:25 -0400 | 
| commit | 5247b7ccf5b5889ee16262dd976b03047e34e32c (patch) | |
| tree | c2a8483ac22f75d842ebc3ad6f3c6f24954b9cef /puppet/modules/postfix/manifests/config.pp | |
| parent | d8a8d30b04d34387f309d9f5b7afdbcad01f7cbc (diff) | |
git subrepo clone https://leap.se/git/puppet_postfix puppet/modules/postfix
subrepo:
  subdir:   "puppet/modules/postfix"
  merged:   "cce918f"
upstream:
  origin:   "https://leap.se/git/puppet_postfix"
  branch:   "master"
  commit:   "cce918f"
git-subrepo:
  version:  "0.3.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "1e79595"
Change-Id: I325a79fe1780ee6a5d61959310cf8e52c9a6896f
Diffstat (limited to 'puppet/modules/postfix/manifests/config.pp')
| -rw-r--r-- | puppet/modules/postfix/manifests/config.pp | 49 | 
1 files changed, 49 insertions, 0 deletions
| diff --git a/puppet/modules/postfix/manifests/config.pp b/puppet/modules/postfix/manifests/config.pp new file mode 100644 index 00000000..ce7af9e4 --- /dev/null +++ b/puppet/modules/postfix/manifests/config.pp @@ -0,0 +1,49 @@ +/* +== Definition: postfix::config + +Uses the "postconf" command to add/alter/remove options in postfix main +configuation file (/etc/postfix/main.cf). + +Parameters: +- *name*: name of the parameter. +- *ensure*: present/absent. defaults to present. +- *value*: value of the parameter. +- *nonstandard*: inform postfix::config that this parameter is not recognized +  by the "postconf" command. defaults to false. + +Requires: +- Class["postfix"] + +Example usage: + +  node "toto.example.com" { + +    class { 'postfix': } + +    postfix::config { +      "smtp_use_tls"            => "yes"; +      "smtp_sasl_auth_enable"   => "yes"; +      "smtp_sasl_password_maps" => "hash:/etc/postfix/my_sasl_passwords"; +      "relayhost"               => "[mail.example.com]:587"; +    } +  } + +*/ +define postfix::config ($ensure = present, $value, $nonstandard = false) { +  case $ensure { +    present: { +      exec {"postconf -e ${name}='${value}'": +        unless  => $nonstandard ? { +          false => "test \"x$(postconf -h ${name})\" = 'x${value}'", +          true  => "test \"x$(egrep '^${name} ' /etc/postfix/main.cf | cut -d= -f2 | cut -d' ' -f2)\" = 'x${value}'", +        }, +        notify  => Service["postfix"], +        require => File["/etc/postfix/main.cf"], +      } +    } + +    absent: { +      fail "postfix::config ensure => absent: Not implemented" +    } +  } +} | 
