Skip to content

Commit

Permalink
Merge pull request #2 from fraenki/postfix_plugins
Browse files Browse the repository at this point in the history
ability to manage plugins
  • Loading branch information
oxc committed Feb 20, 2018
2 parents fb63384 + 5c60444 commit b44b52d
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Add new parameter `$plugins` to specify a list of postfix plugins that should be installed (#2)
- Add new parameter `$plugin` to configure plugin package names (#2)
- Add new parameter `$package_manage` to control wether packages should be installed or not (#2)

### Fixed
- Handle unused main.cf parameters that are unknown by postfix and not referenced
in any other parameter (#3).
- Fix service logic: move exec `restart after package install` to class `postfix::package` (#2)

## Release [0.2.1] - 2018-02-05
Cosmetic release that removes outdated badges from README
Expand Down
9 changes: 9 additions & 0 deletions data/Debian.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
---
postfix::mailx_package: 'bsd-mailx'
postfix::plugin:
ldap:
package_name: ['postfix-ldap']
mysql:
package_name: ['postfix-mysql']
pcre:
package_name: ['postfix-pcre']
pgsql:
package_name: ['postfix-pgsql']
postfix::restart_cmd: '/etc/init.d/postfix reload'
3 changes: 3 additions & 0 deletions data/FreeBSD.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
---
postfix::mailx_package: 'mail/heirloom-mailx'
postfix::plugin:
sasl:
package_name: ['mail/postfix-sasl']
postfix::restart_cmd: '/usr/sbin/service postfix reload'
3 changes: 3 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ postfix::mailx_package: 'mailx'
postfix::mailx_ensure: present
postfix::mailx_manage: true
postfix::package_ensure: present
postfix::package_manage: true
postfix::package_name: 'postfix'
postfix::plugin: {}
postfix::plugins: []
postfix::service_ensure: running
postfix::service_manage: true
postfix::service_name: 'postfix'
13 changes: 13 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
# * `package_ensure`
# The state the postfix package should be ensured.
#
# * `package_manage`
# Whether to install the postfix and plugin packages.
#
# * `package_name`
# * `package_name`
# The name of the postfix package to install.
#
Expand All @@ -30,6 +34,12 @@
# * `mailx_package`
# The name of the mailx package.
#
# * `plugin`
# Contains a package_name parameter for each plugin (if available).
#
# * `plugins`
# The list of plugins to install.
#
# Examples
# --------
#
Expand All @@ -56,7 +66,10 @@
Boolean $mailx_manage,
String $mailx_package,
Enum['installed', 'present', 'latest'] $package_ensure,
Boolean $package_manage,
String $package_name,
Hash $plugin,
Array[String[1]] $plugins,
String $restart_cmd,
Enum['absent', 'running', 'stopped'] $service_ensure,
String $service_name,
Expand Down
31 changes: 28 additions & 3 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,34 @@
# Copyright 2017 Bernhard Frauendienst <puppet@nospam.obeliks.de>
#
class postfix::package inherits postfix {
package { 'postfix':
ensure => $::postfix::package_ensure,
name => $::postfix::package_name,
if ($postfix::package_manage) {
package { 'postfix':
ensure => $postfix::package_ensure,
name => $postfix::package_name,
}

if $::postfix::service_manage {
exec { 'restart postfix service after packages install':
command => regsubst($::postfix::restart_cmd, 'reload', 'restart'),
refreshonly => true,
subscribe => Package['postfix'],
}
}

# get a list of package names for all requested plugins
$_list = $postfix::plugins.map |$_plugin| {
$postfix::plugin.dig($_plugin, 'package_name')
}

# remove duplicates from the list
$packages = unique($_list).filter|$value| { $value != undef }

# install plugin packages
$packages.each |$_package| {
package { $_package:
ensure => $postfix::package_ensure,
}
}
}

if ($::postfix::mailx_manage) {
Expand Down
5 changes: 0 additions & 5 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
}

if $::postfix::service_manage {
exec { 'restart postfix after packages install':
command => regsubst($::postfix::restart_cmd, 'reload', 'restart'),
refreshonly => true,
subscribe => Package['postfix'],
}
service { 'postfix':
ensure => $service_ensure_real,
name => $::postfix::service_name,
Expand Down

0 comments on commit b44b52d

Please sign in to comment.