Skip to content
Snippets Groups Projects
Select Git revision
  • f87e8e9a19c284b8ed4c3f6e961322b39e29e348
  • master default protected
  • release_4.0.0
  • laminas_migration
  • 4.0.0
  • 3.0.3
  • 3.0.2
  • 3.0.1
  • 3.0.0
  • 1.2.15
  • 1.2.14
  • 1.2.13
  • 1.2.12
  • 1.2.11
  • 1.2.10
  • 1.2.9
  • 1.2.8
  • 1.2.7
  • 1.2.6
  • 1.2.5
  • 1.2.4
  • 1.2.3
  • 1.2.2
  • 1.2.1
24 results

DataService.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    virtual.pp 1.83 KiB
    # == Definition: postfix::virtual
    #
    # Manages content of the /etc/postfix/virtual map.
    #
    # === Parameters
    #
    # [*name*]        - name of address postfix will lookup. See virtual(8).
    # [*destination*] - where the emails will be delivered to. See virtual(8).
    # [*ensure*]      - present/absent, defaults to present.
    # [*file*]        - A string defining the location of the pre-hash map.
    #
    # === Requires
    #
    # - Class["postfix"]
    # - Postfix::Hash["/etc/postfix/virtual"]
    # - Postfix::Config["virtual_alias_maps"]
    # - augeas
    #
    # === Examples
    #
    #   node "toto.example.com" {
    #
    #     include postfix
    #
    #     postfix::hash { "/etc/postfix/virtual":
    #       ensure => present,
    #     }
    #     postfix::config { "virtual_alias_maps":
    #       value => "hash:/etc/postfix/virtual"
    #     }
    #     postfix::virtual { "user@example.com":
    #       ensure      => present,
    #       destination => "root",
    #     }
    #   }
    #
    define postfix::virtual (
      String                    $destination,
      Stdlib::Absolutepath      $file='/etc/postfix/virtual',
      Enum['present', 'absent'] $ensure='present'
    ) {
      include ::postfix::augeas
    
      case $ensure {
        'present': {
          $changes = [
            "set pattern[. = '${name}'] '${name}'",
            # TODO: support more than one destination
            "set pattern[. = '${name}']/destination '${destination}'",
          ]
        }
    
        'absent': {
          $changes = "rm pattern[. = '${name}']"
        }
    
        default: {
          fail "\$ensure must be either 'present' or 'absent', got '${ensure}'"
        }
      }
    
      augeas {"Postfix virtual - ${name}":
        incl    => $file,
        lens    => 'Postfix_Virtual.lns',
        changes => $changes,
        require => Augeas::Lens['postfix_virtual'],
      }
    
      if defined(Package['postfix']) {
        Package['postfix'] -> Postfix::Virtual[$title]
      }
    
      if defined(Postfix::Hash[$file]) {
        Postfix::Virtual[$title] ~> Postfix::Hash[$file]
      }
    }