Skip to content
Snippets Groups Projects
Select Git revision
  • 262ee39fcdf93e2a91edb8ff2edad18cb325e479
  • main default
  • detached3
  • detached2
  • modernisation-gestion-donnees
  • detached
  • 1.5.0
  • 1.4.3
  • 1.4.2
  • 1.4.1
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.2
  • 1.1.1
  • 1.1.0
  • 1.0.6
  • 1.0.5
  • 1.0.4
  • 1.0.3
  • 1.0.2
  • 1.0.1
  • 1.0.0
  • 0.9.10
  • 0.9.9
  • 0.9.8
26 results

autoload_classmap.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    config.pp 1.54 KiB
    #
    # == Definition: postfix::config
    #
    # Uses Augeas to add/alter/remove options in postfix main
    # configuation file (/etc/postfix/main.cf).
    #
    # TODO: make this a type with an Augeas and a postconf providers.
    #
    # === Parameters
    #
    # [*name*]   - name of the parameter.
    # [*ensure*] - present/absent/blank. defaults to present.
    # [*value*]  - value of the parameter.
    #
    # === Requires
    #
    # - Class["postfix"]
    #
    # === Examples
    #
    #   postfix::config { 'smtp_use_tls':
    #     ensure => 'present',
    #     value  => 'yes',
    #   }
    #
    #   postfix::config { 'relayhost':
    #     ensure => 'blank',
    #   }
    #
    define postfix::config ($value = undef, $ensure = 'present') {
    
      validate_string($ensure)
      validate_re($ensure, ['present', 'absent', 'blank'],
        "\$ensure must be either 'present', 'absent' or 'blank', got '${ensure}'")
      if ($ensure == 'present') {
        validate_string($value)
        validate_re($value, '^.+$',
          '$value can not be empty if ensure = present')
      }
    
      if (!defined(Class['postfix'])) {
        fail 'You must define class postfix before using postfix::config!'
      }
    
      Augeas {
        incl    => '/etc/postfix/main.cf',
        lens    => 'Postfix_Main.lns',
        require => File['/etc/postfix/main.cf'],
      }
    
      case $ensure {
        present: {
          augeas { "set postfix '${name}' to '${value}'":
            changes => "set ${name} '${value}'",
          }
        }
        absent: {
          augeas { "rm postfix '${name}'":
            changes => "rm ${name}",
          }
        }
        blank: {
          augeas { "blank postfix '${name}'":
            changes => "clear ${name}",
          }
        }
        default: {}
      }
    }