aboutsummaryrefslogtreecommitdiffstats
path: root/modules/opendkim/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/opendkim/manifests')
-rw-r--r--modules/opendkim/manifests/domain.pp46
-rw-r--r--modules/opendkim/manifests/init.pp105
-rw-r--r--modules/opendkim/manifests/trusted.pp13
3 files changed, 164 insertions, 0 deletions
diff --git a/modules/opendkim/manifests/domain.pp b/modules/opendkim/manifests/domain.pp
new file mode 100644
index 00000000..c708ad08
--- /dev/null
+++ b/modules/opendkim/manifests/domain.pp
@@ -0,0 +1,46 @@
+define opendkim::domain (
+ $domain = $name,
+ $selector = $hostname,
+ $pathkeys = '/etc/opendkim/keys',
+ $keytable = 'KeyTable',
+ $signing_table = 'SigningTable',
+) {
+ # $pathConf and $pathKeys must be without trailing '/'.
+ # For example, '/etc/opendkim/keys'
+
+ Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ] }
+
+ # Create directory for domain
+ file { "${pathkeys}/${domain}":
+ ensure => directory,
+ owner => $opendkim::owner,
+ group => $opendkim::group,
+ mode => '0755',
+ notify => Service[$opendkim::service_name],
+ require => Package[$opendkim::package_name],
+ }
+
+ # Generate dkim-keys
+ exec { "opendkim-genkey -D ${pathkeys}/${domain}/ -d ${domain} -s ${selector}":
+ unless => "/usr/bin/test -f ${pathkeys}/${domain}/${selector}.private && /usr/bin/test -f ${pathkeys}/${domain}/${selector}.txt",
+ user => $opendkim::owner,
+ notify => Service[$opendkim::service_name],
+ require => [ Package[$opendkim::package_name], File["${pathkeys}/${domain}"], ],
+ }
+
+ # Add line into KeyTable
+ file_line { "${opendkim::pathconf}/${keytable}_${domain}":
+ path => "${opendkim::pathconf}/${keytable}",
+ line => "${selector}._domainkey.${domain} ${domain}:${selector}:${pathkeys}/${domain}/${selector}.private",
+ notify => Service[$opendkim::service_name],
+ require => Package[$opendkim::package_name],
+ }
+
+ # Add line into SigningTable
+ file_line { "${opendkim::pathconf}/${signing_table}_${domain}":
+ path => "${opendkim::pathconf}/${signing_table}",
+ line => "*@${domain} ${selector}._domainkey.${domain}",
+ notify => Service[$opendkim::service_name],
+ require => Package[$opendkim::package_name],
+ }
+}
diff --git a/modules/opendkim/manifests/init.pp b/modules/opendkim/manifests/init.pp
new file mode 100644
index 00000000..6e45345a
--- /dev/null
+++ b/modules/opendkim/manifests/init.pp
@@ -0,0 +1,105 @@
+# == Class: opendkim
+#
+# === Examples
+#
+# class { 'opendkim':}
+#
+# === Authors
+#
+# Vladimir Bykanov <vladimir@bykanov.ru>
+#
+# === Copyright
+#
+# Copyright 2015 Vladimir Bykanov
+#
+class opendkim (
+ $autorestart = 'Yes',
+ $autorestart_rate = '10/1h',
+ $log_why = 'Yes',
+ $syslog = 'Yes',
+ $syslog_success = 'Yes',
+ $mode = 's',
+ $canonicalization = 'relaxed/simple',
+ $external_ignore_list = 'refile:/etc/opendkim/TrustedHosts',
+ $internal_hosts = 'refile:/etc/opendkim/TrustedHosts',
+ $keytable = 'refile:/etc/opendkim/KeyTable',
+ $signing_table = 'refile:/etc/opendkim/SigningTable',
+ $signature_algorithm = 'rsa-sha256',
+ $socket = 'inet:8891@localhost',
+ $pidfile = '/var/run/opendkim/opendkim.pid',
+ $umask = '022',
+ $userid = 'opendkim:opendkim',
+ $temporary_directory = '/var/tmp',
+ $package_name = 'opendkim',
+ $service_name = 'opendkim',
+ $pathconf = '/etc/opendkim',
+ $owner = 'opendkim',
+ $group = 'opendkim',
+) {
+
+ package { $package_name:
+ ensure => present,
+ }
+
+ case $::operatingsystem {
+ /^(Debian|Ubuntu)$/: {
+ package { 'opendkim-tools':
+ ensure => present,
+ }
+ # Debian/Ubuntu doesn't ship this directory in its package
+ file { $pathconf:
+ ensure => directory,
+ owner => 'root',
+ group => 'opendkim',
+ mode => '0755',
+ require => Package[$package_name],
+ }
+ file { "${pathconf}/keys":
+ ensure => directory,
+ owner => 'opendkim',
+ group => 'opendkim',
+ mode => '0750',
+ require => Package[$package_name],
+ }
+ file { "${pathconf}/KeyTable":
+ ensure => present,
+ owner => 'opendkim',
+ group => 'opendkim',
+ mode => '0640',
+ require => Package[$package_name],
+ }
+ file { "${pathconf}/SigningTable":
+ ensure => present,
+ owner => 'opendkim',
+ group => 'opendkim',
+ mode => '0640',
+ require => Package[$package_name],
+ }
+ file { "${pathconf}/TrustedHosts":
+ ensure => present,
+ owner => 'opendkim',
+ group => 'opendkim',
+ mode => '0644',
+ require => Package[$package_name],
+ }
+ }
+ default: {}
+ }
+
+ file {'/etc/opendkim.conf':
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ content => template('opendkim/opendkim.conf'),
+ notify => Service[$service_name],
+ require => Package[$package_name],
+ }
+
+ service { $service_name:
+ ensure => running,
+ enable => true,
+ require => Package[$package_name],
+ }
+}
+
diff --git a/modules/opendkim/manifests/trusted.pp b/modules/opendkim/manifests/trusted.pp
new file mode 100644
index 00000000..dcf0f8b8
--- /dev/null
+++ b/modules/opendkim/manifests/trusted.pp
@@ -0,0 +1,13 @@
+define opendkim::trusted (
+ $host = $name,
+ $trusted_hosts = 'TrustedHosts',
+
+) {
+ # Add line into KeyTable
+ file_line { "${opendkim::pathconf}/${trusted_hosts}_${host}":
+ path => "${opendkim::pathconf}/${trusted_hosts}",
+ line => $host,
+ notify => Service[$opendkim::service_name],
+ require => Package[$opendkim::package_name],
+ }
+}