diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2016-06-18 09:45:56 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2016-06-18 09:45:56 -0300 |
commit | 357609e0b8ace0971efcbdeceabcc96f4097b203 (patch) | |
tree | 0e816eb36cb433edad9df130d4ce222eda5c2842 | |
parent | 8734feea565a6679840a755e6399ad3fb87b7d2c (diff) | |
download | puppet-postfix-357609e0b8ace0971efcbdeceabcc96f4097b203.tar.gz puppet-postfix-357609e0b8ace0971efcbdeceabcc96f4097b203.tar.bz2 |
Migrate transport_regexp and virtual_regexp to concat
-rw-r--r-- | manifests/transport_regexp.pp | 38 | ||||
-rw-r--r-- | manifests/transport_regexp_snippet.pp | 21 | ||||
-rw-r--r-- | manifests/virtual_regexp.pp | 39 | ||||
-rw-r--r-- | manifests/virtual_regexp_snippet.pp | 21 |
4 files changed, 34 insertions, 85 deletions
diff --git a/manifests/transport_regexp.pp b/manifests/transport_regexp.pp index 4961141..6d86a54 100644 --- a/manifests/transport_regexp.pp +++ b/manifests/transport_regexp.pp @@ -21,36 +21,18 @@ # class postfix::transport_regexp { - include common::moduledir - common::module_dir{'postfix/transport_regexp': } - - $postfix_transport_regexp_dir = "${common::moduledir::module_dir_path}/postfix/transport_regexp" - $postfix_transport_regexp_snippets_dir = "${postfix_transport_regexp_dir}/transport_regexp.d" - $postfix_merged_transport_regexp = "${postfix_transport_regexp_dir}/merged_transport_regexp" - - file {"$postfix_transport_regexp_snippets_dir": - ensure => 'directory', - owner => 'root', - group => '0', - mode => '700', - source => [ - "puppet:///modules/site_postfix/${fqdn}/transport_regexp.d", - "puppet:///modules/site_postfix/transport_regexp.d", - "puppet:///files/etc/postfix/transport_regexp.d", - "puppet:///modules/postfix/transport_regexp.d", - ], - recurse => true, - purge => false, - } - - concatenated_file { "$postfix_merged_transport_regexp": - dir => "${postfix_transport_regexp_snippets_dir}", - require => File["$postfix_transport_regexp_snippets_dir"], + concat { '/etc/postfix/transport_regex': + owner => root, + group => root, + mode => '0600', } - config_file { '/etc/postfix/transport_regexp': - source => "$postfix_merged_transport_regexp", - subscribe => File["$postfix_merged_transport_regexp"], + # Cleanup previous implementation's internal files + include common::moduledir + file { "${common::moduledir::module_dir_path}/postfix/transport_regexp": + ensure => absent, + recurse => true, + force => true, } } diff --git a/manifests/transport_regexp_snippet.pp b/manifests/transport_regexp_snippet.pp index 2b13ed1..88c72e1 100644 --- a/manifests/transport_regexp_snippet.pp +++ b/manifests/transport_regexp_snippet.pp @@ -25,7 +25,7 @@ Example usage: define postfix::transport_regexp_snippet ( $ensure = "present", - $source = '', + $source = '', $content = undef ) { @@ -37,29 +37,22 @@ define postfix::transport_regexp_snippet ( fail("Only one of \$source or \$content must specified for postfix::transport_regexp_snippet ${name}") } - if ($value == false) and ($ensure == "present") { - fail("The value parameter must be set when using the postfix::transport_regexp_snippet define with ensure=present.") - } - include postfix::transport_regexp - $snippetfile = "${postfix::transport_regexp::postfix_transport_regexp_snippets_dir}/${name}" - - file { "$snippetfile": + $fragment = "postfix_transport_regexp_${name}" + + concat::fragment { "$fragment": ensure => "$ensure", - mode => 600, - owner => root, - group => 0, - notify => Exec["concat_${postfix::transport_regexp::postfix_merged_transport_regexp}"], + target => '/etc/postfix/transport_regexp', } if $source { - File["$snippetfile"] { + Concat::Fragment["$fragment"] { source => $source, } } else { - File["$snippetfile"] { + Concat::Fragment["$fragment"] { content => $content, } } diff --git a/manifests/virtual_regexp.pp b/manifests/virtual_regexp.pp index 18bbd8c..c3a57d9 100644 --- a/manifests/virtual_regexp.pp +++ b/manifests/virtual_regexp.pp @@ -21,36 +21,17 @@ # class postfix::virtual_regexp { - include common::moduledir - common::module_dir{'postfix/virtual_regexp': } - - $postfix_virtual_regexp_dir = "${common::moduledir::module_dir_path}/postfix/virtual_regexp" - $postfix_virtual_regexp_snippets_dir = "${postfix_virtual_regexp_dir}/virtual_regexp.d" - $postfix_merged_virtual_regexp = "${postfix_virtual_regexp_dir}/merged_virtual_regexp" - - file {"$postfix_virtual_regexp_snippets_dir": - ensure => 'directory', - owner => 'root', - group => '0', - mode => '700', - source => [ - "puppet:///modules/site_postfix/${fqdn}/virtual_regexp.d", - "puppet:///modules/site_postfix/virtual_regexp.d", - "puppet:///files/etc/postfix/virtual_regexp.d", - "puppet:///modules/postfix/virtual_regexp.d", - ], - recurse => true, - purge => false, + concat { '/etc/postfix/virtual_regexp': + owner => root, + group => root, + mode => '0600', } - concatenated_file { "$postfix_merged_virtual_regexp": - dir => "${postfix_virtual_regexp_snippets_dir}", - require => File["$postfix_virtual_regexp_snippets_dir"], - } - - config_file { '/etc/postfix/virtual_regexp': - source => "$postfix_merged_virtual_regexp", - subscribe => File["$postfix_merged_virtual_regexp"], + # Cleanup previous implementation's internal files + include common::moduledir + file { "${common::moduledir::module_dir_path}/postfix/virtual_regexp": + ensure => absent, + recurse => true, + force => true, } - } diff --git a/manifests/virtual_regexp_snippet.pp b/manifests/virtual_regexp_snippet.pp index bd9a982..6252fd2 100644 --- a/manifests/virtual_regexp_snippet.pp +++ b/manifests/virtual_regexp_snippet.pp @@ -25,7 +25,7 @@ Example usage: define postfix::virtual_regexp_snippet ( $ensure = "present", - $source = '', + $source = '', $content = undef ) { @@ -37,29 +37,22 @@ define postfix::virtual_regexp_snippet ( fail("Only one of \$source or \$content must specified for postfix::virtual_regexp_snippet ${name}") } - if ($value == false) and ($ensure == "present") { - fail("The value parameter must be set when using the postfix::virtual_regexp_snippet define with ensure=present.") - } - include postfix::virtual_regexp - $snippetfile = "${postfix::virtual_regexp::postfix_virtual_regexp_snippets_dir}/${name}" - - file { "$snippetfile": + $fragment = "postfix_virtual_regexp_${name}" + + concat::fragment { "$fragment": ensure => "$ensure", - mode => 600, - owner => root, - group => 0, - notify => Exec["concat_${postfix::virtual_regexp::postfix_merged_virtual_regexp}"], + target => '/etc/postfix/virtual_regexp', } if $source { - File["$snippetfile"] { + Concat::Fragment["$fragment"] { source => $source, } } else { - File["$snippetfile"] { + Concat::Fragment["$fragment"] { content => $content, } } |