Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Puppet Camptocamp Postfix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Projets publics
Puppet Camptocamp Postfix
Commits
f9a114b2
Commit
f9a114b2
authored
6 years ago
by
Raphaël Pinson
Committed by
Raphaël Pinson
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Support multiple destinations in postfix::virtual (Fix #164)
parent
e8fe4c71
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
manifests/virtual.pp
+16
-12
16 additions, 12 deletions
manifests/virtual.pp
spec/defines/postfix_virtual_spec.rb
+27
-5
27 additions, 5 deletions
spec/defines/postfix_virtual_spec.rb
with
43 additions
and
17 deletions
manifests/virtual.pp
+
16
−
12
View file @
f9a114b2
...
...
@@ -5,9 +5,9 @@
# === Parameters
#
# [*name*] - name of address postfix will lookup. See virtual(8).
# [*destination*] - where the emails will be delivered to. See virtual(8).
# [*destination*] -
a list of destinations
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.
# [*file*] -
a
string defining the location of the pre-hash map.
#
# === Requires
#
...
...
@@ -21,8 +21,7 @@
# node "toto.example.com" {
#
# include postfix
#
# postfix::hash { "/etc/postfix/virtual":
# # postfix::hash { "/etc/postfix/virtual":
# ensure => present,
# }
# postfix::config { "virtual_alias_maps":
...
...
@@ -30,24 +29,29 @@
# }
# postfix::virtual { "user@example.com":
# ensure => present,
# destination =>
"
root
"
,
# destination =>
['
root
', 'postmaster']
,
# }
# }
#
define
postfix::virtual
(
String
$destination
,
Variant
[
String
,
Array
[
String
]]
$destination
,
Stdlib
::
Absolutepath
$file
=
'/etc/postfix/virtual'
,
Enum
[
'present'
,
'absent'
]
$ensure
=
'present'
)
{
include
::postfix::augeas
$dest_sets
=
[
$destination
]
.
flatten
.
map
|
$i
,
$d
|
{
$idx
=
$i
+
1
"set
\$
entry/destination[
${idx}
] '
${d}
'"
}
case
$ensure
{
'present'
:
{
$changes
=
[
"
set
pattern[. = '
${name}
'] '
${name}
'"
,
# TODO: support more than one
destination
"set pattern[. = '
${name}
']/destination '
${destination}
'"
,
]
"
defnode entry
pattern[. = '
${name}
'] '
${name}
'"
,
'rm $entry/
destination
'
,
$dest_sets
,
]
.
flatten
}
'absent'
:
{
...
...
This diff is collapsed.
Click to expand it.
spec/defines/postfix_virtual_spec.rb
+
27
−
5
View file @
f9a114b2
...
...
@@ -26,7 +26,7 @@ describe 'postfix::virtual' do
context
'when sending wrong type for destination'
do
let
(
:params
)
{
{
:destination
=>
[
'bar'
]
,
:destination
=>
true
,
}
}
it
'should fail'
do
...
...
@@ -98,8 +98,9 @@ describe 'postfix::virtual' do
:incl
=>
'/etc/postfix/virtual'
,
:lens
=>
'Postfix_Virtual.lns'
,
:changes
=>
[
"set pattern[. = 'foo'] 'foo'"
,
"set pattern[. = 'foo']/destination 'bar'"
,
"defnode entry pattern[. = 'foo'] 'foo'"
,
"rm $entry/destination"
,
"set $entry/destination[1] 'bar'"
,
])
}
end
...
...
@@ -116,8 +117,29 @@ describe 'postfix::virtual' do
:incl
=>
'/tmp/virtual'
,
:lens
=>
'Postfix_Virtual.lns'
,
:changes
=>
[
"set pattern[. = 'foo'] 'foo'"
,
"set pattern[. = 'foo']/destination 'bar'"
,
"defnode entry pattern[. = 'foo'] 'foo'"
,
"rm $entry/destination"
,
"set $entry/destination[1] 'bar'"
,
])
}
end
context
'when passing destination as array'
do
let
(
:params
)
{
{
:destination
=>
[
'bar'
,
'baz'
],
:file
=>
'/tmp/virtual'
,
:ensure
=>
'present'
,
}
}
it
{
is_expected
.
to
contain_class
(
'postfix::augeas'
)
}
it
{
is_expected
.
to
contain_augeas
(
'Postfix virtual - foo'
).
with
(
:incl
=>
'/tmp/virtual'
,
:lens
=>
'Postfix_Virtual.lns'
,
:changes
=>
[
"defnode entry pattern[. = 'foo'] 'foo'"
,
"rm $entry/destination"
,
"set $entry/destination[1] 'bar'"
,
"set $entry/destination[2] 'baz'"
,
])
}
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment