Skip to content
Snippets Groups Projects
Select Git revision
  • 2d1906b391362c507a842f36c78f3763e3245c71
  • master default protected
  • update-min-openvox-version-07f8cb2
  • 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
  • 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

canonical.pp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    canonical.pp 1.69 KiB
    #== Definition: postfix::canonical
    #
    #Manages content of the /etc/postfix/canonical map.
    #
    #Parameters:
    #- *name*: name of address postfix will lookup. See canonical(5).
    #- *destination*: where the emails will be delivered to. See canonical(5).
    #- *ensure*: present/absent, defaults to present.
    #
    #Requires:
    #- Class["postfix"]
    #- Postfix::Hash["/etc/postfix/canonical"]
    #- Postfix::Config["canonical_maps"] or Postfix::Config["sender_canonical_maps"] or Postfix::Config["recipient_canonical_maps"]
    #- augeas
    #
    #Example usage:
    #
    #  node "toto.example.com" {
    #
    #    include postfix
    #
    #    postfix::hash { "/etc/postfix/recipient_canonical":
    #      ensure => present,
    #    }
    #    postfix::config { "canonical_alias_maps":
    #      value => "hash:/etc/postfix/recipient_canonical"
    #    }
    #    postfix::canonical {
    #      "user@example.com":
    #        file        => "/etc/postfix/recipient_canonical",
    #        ensure      => present,
    #        destination => "root";
    #    }
    #  }
    #
    define postfix::canonical (
      $destination,
      $file=undef,
      $ensure='present'
    ) {
      include postfix
      include ::postfix::augeas
    
      $_file = pick($file, "${postfix::confdir}/canonical")
    
      case $ensure {
        'present': {
          $changes = [
            "set pattern[. = '${name}'] '${name}'",
            "set pattern[. = '${name}']/destination '${destination}'",
          ]
        }
    
        'absent': {
          $changes = "rm pattern[. = '${name}']"
        }
    
        default: {
          fail("Wrong ensure value: ${ensure}")
        }
      }
    
      augeas {"Postfix canonical - ${name}":
        incl    => $_file,
        lens    => 'Postfix_Canonical.lns',
        changes => $changes,
        require => [Package['postfix'], Augeas::Lens['postfix_canonical']],
        notify  => Exec["generate ${_file}.db"],
      }
    }