Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Hiera support for postfix::config, postfix::hash, postfix::transport and postfix::virtual #50

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
#
# [*use_sympa*] - (boolean) Whether to setup for Sympa
#
# [*configs*] - (hash) postfix::config definitions (for Hiera usage)
#
# [*hashs*] - (hash) postfix::hash definitions (for Hiera usage)
#
# [*transports*] - (hash) postfix::transport definitions (for Hiera usage)
#
# [*virtuals*] - (hash) postfix::virtual definitions (for Hiera usage)
#
# === Examples
#
# class { 'postfix':
Expand Down Expand Up @@ -92,6 +100,10 @@
$use_dovecot_lda = false, # postfix_use_dovecot_lda
$use_schleuder = false, # postfix_use_schleuder
$use_sympa = false, # postfix_use_sympa
$configs = {},
$hashs = {},
$transports = {},
$virtuals = {},
) inherits postfix::params {


Expand Down Expand Up @@ -123,7 +135,15 @@
}
validate_string($smtp_listen)

validate_hash($configs)
validate_hash($hashs)
validate_hash($transports)
validate_hash($virtuals)

create_resources('postfix::config', $configs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_resources should be done in postfix::config class

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can't be done in postfix::config since this is define type... My proposed way is the recommend way to implement hiera support.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right, not in postfix::config, in postfix::files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But thats not the way other module work. I just want to do 'include postfix' and everything else is done in hiera. If i would implemented it that way you suggest, i would also need to do 'include postfix::files'. I don't see any benefit here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, postfix::files is included in init, so no need to include it afterwards.
Keep the params to init class like you did, but create the resources in postfix::files instead of in init this should fix the cyclic dependency.

create_resources('postfix::hash', $hashs)
create_resources('postfix::transport', $transports)
create_resources('postfix::virtual', $virtuals)

$_smtp_listen = $mailman ? {
true => '0.0.0.0',
Expand All @@ -137,8 +157,7 @@

class { 'postfix::packages': } ->
class { 'postfix::files': } ~>
class { 'postfix::service': } ->
Class['postfix']
class { 'postfix::service': }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should work if create_resources is done in postfix::config subclass


if $ldap {
include ::postfix::ldap
Expand All @@ -164,5 +183,4 @@

# Relationships
Postfix::Config <| |> ~> Class['postfix::service']
Class['postfix'] -> Postfix::Hash <| |>
}