Skip to content
Snippets Groups Projects
Select Git revision
  • 1ca99d5d1d7b3dbf624c3b7ad1b15698b5cce1e5
  • master default protected
  • main
  • update_github_actions
  • 144_rocky8_support
  • 195-update-pdk-to-300
  • 144-rocky8
  • add_test_github_test_workflow
  • pdk_2.4.0
  • fix_unclosed_let_block_in_defines_client_spec
  • validation_fixes
  • freeradius_3_0_21_config_updates
  • data_types
  • PrepareBuster
  • travis
  • 4.0.1
  • 4.0.0
  • 3.9.2
  • 3.9.1
  • 3.9.0
  • 3.8.2
  • 3.8.1
  • 3.8.0
  • 3.7.0
  • 3.6.0
  • 3.5.0
  • 3.4.3
  • 3.4.2
  • 3.4.1
  • 3.4.0
  • 3.3.0
  • 3.2.0
  • 3.1.0
  • 3.0.0
  • 2.3.1
35 results

template.header

Blame
  • 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"
        }
      }
    }