Skip to content
Snippets Groups Projects
Select Git revision
  • 9cfb03fef5af5d2a75334e527b088f9713a87b3f
  • master default protected
  • cleanup_fixtures
  • add-openvox
  • freebsd-14
  • remove-legacy-top-scope-syntax
  • rel430
  • tests
  • revert-363-augeas-module-cleanup
  • release-4.1.0
  • puppet8
  • relax-dependencies
  • rel400
  • mode
  • puppet7
  • release-3.1.0
  • freebsd13
  • freebsd11
  • stdlib
  • centos
  • fedora
  • v5.1.0
  • v5.0.0
  • v4.5.0
  • v4.4.0
  • v4.3.0
  • v4.2.1
  • v4.2.0
  • v4.1.0
  • v4.0.0
  • v3.1.0
  • v3.0.0
  • v2.0.0
  • 1.12.0
  • 1.11.0
  • 1.10.0
  • 1.9.0
  • 1.8.0
  • 1.7.0
  • 1.6.0
  • 1.5.0
41 results

config.pp

Blame
  • user avatar
    Marc Fournier authored
    1c249d42
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    config.pp 1.31 KiB
    /*
    == 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" {
    
        include 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"
        }
      }
    }