Giter Site home page Giter Site logo

sous-chefs / postfix Goto Github PK

View Code? Open in Web Editor NEW
103.0 50.0 154.0 489 KB

Development repository for the postfix cookbook

Home Page: https://supermarket.chef.io/cookbooks/postfix

License: Apache License 2.0

Ruby 87.32% HTML 12.68%
chef hacktoberfest chef-cookbook chef-resource postfix managed-by-terraform

postfix's Introduction

postfix Cookbook

Cookbook Version CI State OpenCollective OpenCollective License

Installs and configures postfix for client or outbound relayhost, or to do SASL authentication.

On RHEL-family systems, sendmail will be replaced with postfix.

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Requirements

Platforms

  • Ubuntu
  • Debian
  • RHEL/CentOS/Scientific
  • Amazon Linux (as of AMIs created after 4/9/2012)
  • FreeBSD

May work on other platforms with or without modification.

Chef

  • Chef 12.1+

Cookbooks

  • none

Attributes

See attributes/default.rb for default values.

Generic cookbook attributes

  • node['postfix']['mail_type'] - Sets the kind of mail configuration. master will set up a server (relayhost).
  • node['postfix']['relayhost_role'] - name of a role used for search in the client recipe.
  • node['postfix']['relayhost_port'] - listening network port of the relayhost.
  • node['postfix']['multi_environment_relay'] - set to true if nodes should not constrain search for the relayhost in their own environment.
  • node['postfix']['use_procmail'] - set to true if nodes should use procmail as the delivery agent.
  • node['postfix']['use_alias_maps'] - set to true if you want the cookbook to use/configure alias maps
  • node['postfix']['use_transport_maps'] - set to true if you want the cookbook to use/configure transport maps
  • node['postfix']['use_access_maps'] - set to true if you want the cookbook to use/configure access maps
  • node['postfix']['use_virtual_aliases'] - set to true if you want the cookbook to use/configure virtual alias maps
  • node['postfix']['use_relay_restrictions_maps'] - set to true if you want the cookbook to use/configure a list of domains to which postfix will allow relay
  • node['postfix']['aliases'] - hash of aliases to create with recipe[postfix::aliases], see below under Recipes for more information.
  • node['postfix']['transports'] - hash of transports to create with recipe[postfix::transports], see below under Recipes for more information.
  • node['postfix']['access'] - hash of access to create with recipe[postfix::access], see below under Recipes for more information.
  • node['postfix']['virtual_aliases'] - hash of virtual_aliases to create with recipe[postfix::virtual_aliases], see below under Recipes for more information.
  • node['postfix']['main_template_source'] - Cookbook source for main.cf template. Default 'postfix'
  • node['postfix']['master_template_source'] - Cookbook source for master.cf template. Default 'postfix'

main.cf and sasl_passwd template attributes

The main.cf template has been simplified to include any attributes in the node['postfix']['main'] data structure. The following attributes are still included with this cookbook to maintain some semblance of backwards compatibility.

This change in namespace to node['postfix']['main'] should allow for greater flexibility, given the large number of configuration variables for the postfix daemon. All of these cookbook attributes correspond to the option of the same name in /etc/postfix/main.cf.

  • node['postfix']['main']['biff'] - (yes/no); default no
  • node['postfix']['main']['append_dot_mydomain'] - (yes/no); default no
  • node['postfix']['main']['myhostname'] - defaults to fqdn from Ohai
  • node['postfix']['main']['mydomain'] - defaults to domain from Ohai
  • node['postfix']['main']['myorigin'] - defaults to $myhostname
  • node['postfix']['main']['mynetworks'] - default is nil, which forces Postfix to default to loopback addresses.
  • node['postfix']['main']['inet_interfaces'] - set to loopback-only, or all for server recipe
  • node['postfix']['main']['alias_maps'] - set to hash:/etc/aliases
  • node['postfix']['main']['mailbox_size_limit'] - set to 0 (disabled)
  • node['postfix']['main']['mydestination'] - default fqdn, hostname, localhost.localdomain, localhost
  • node['postfix']['main']['smtpd_use_tls'] - (yes/no); default yes. See conditional cert/key attributes.
  • node['postfix']['main']['smtpd_tls_cert_file'] - conditional attribute, set to full path of server's x509 certificate.
  • node['postfix']['main']['smtpd_tls_key_file'] - conditional attribute, set to full path of server's private key
  • node['postfix']['main']['smtpd_tls_CAfile'] - set to platform specific CA bundle
  • node['postfix']['main']['smtpd_tls_session_cache_database'] - set to btree:${data_directory}/smtpd_scache
  • node['postfix']['main']['smtp_use_tls'] - (yes/no); default yes. See following conditional attributes.
  • node['postfix']['main']['smtp_tls_CAfile'] - set to platform specific CA bundle
  • node['postfix']['main']['smtp_tls_session_cache_database'] - set to btree:${data_directory}/smtpd_scache
  • node['postfix']['main']['smtp_sasl_auth_enable'] - (yes/no); default no. If enabled, see following conditional attributes.
  • node['postfix']['main']['smtp_sasl_password_maps'] - Set to hash:/etc/postfix/sasl_passwd template file
  • node['postfix']['main']['smtp_sasl_security_options'] - Set to noanonymous
  • node['postfix']['main']['relayhost'] - Set to empty string
  • node['postfix']['sender_canonical_map_entries'] - (hash with key value pairs); default not configured. Setup generic canonical maps. See man 5 canonical. If has at least one value, then will be enabled in config.
  • node['postfix']['smtp_generic_map_entries'] - (hash with key value pairs); default not configured. Setup generic postfix maps. See man 5 generic. If has at least one value, then will be enabled in config.
  • node['postfix']['recipient_canonical_map_entries'] - (hash with key value pairs); default not configured. Setup generic canonical maps. See man 5 canonical. If has at least one value, then will be enabled in config.
  • node['postfix']['sasl']['smtp_sasl_user_name'] - SASL user to authenticate as. Default empty. You can only use this until the current version. The new syntax is below.
  • node['postfix']['sasl']['smtp_sasl_passwd'] - SASL password to use. Default empty. You can only use this until the current version. The new syntax is below.
  • node['postfix']['sasl'] = json { "relayhost1" => { 'username' => 'foo', 'password' => 'bar' }, "relayhost2" => { ... } } - You must set the following attribute, otherwise the attribute will default to empty

Example of json role config, for setup *_map_entries:

postfix : {

...

"smtp_generic_map_entries" : { "[email protected]" : "[email protected]", "[email protected]" : "[email protected]" }

}

master.cf template attributes

The master.cf template has been changed to allow full customization of the file content. For purpose of backwards compatibility default attributes generate the same master.cf. But via node['postfix']['master'] data structure in your role for instance it can be completelly rewritten.

Examples of json role config, for customize master.cf:

postfix : {

...

turn some services off or on:

  "master" : {
    "smtps": {
      "active": true
    },
    "old-cyrus": {
      "active": false
    },
    "cyrus": {
      "active": false
    },
    "uucp": {
      "active": false
    },
    "ifmail": {
      "active": false
    },

... define you own service:

    "spamfilter": {
      "comment": "My own spamfilter",
      "active": true,
      "order": 590,
      "type": "unix",
      "unpriv": false,
      "chroot": false,
      "command": "pipe",
      "args": ["flags=Rq user=spamd argv=/usr/bin/spamfilter.sh -oi -f ${sender} ${recipient}"]
    }

...

} }

The possible service hash fields and their meanings: hash key - have to be unique, unless you wish to override default definition.

Field Mandatory Description
active Yes Boolean. Defines whether or not the service needs to be in master.cf
comment No String. If you would like to add a comment line before service line
order Yes Integer. Number to define the order of lines in the file
type Yes String. Type of the service (inet, unix, fifo)
private No Boolean. If present replaced by y or n, otherwise by -
unpriv No Boolean. If present replaced by y or n, otherwise by -
chroot No Boolean. If present replaced by y or n, otherwise by -
wakeup No String. If present value placed in file, otherwise replaced by -
maxproc No String. If present value placed in file, otherwise replaced by -
command Yes String. The command to be executed.
args Yes Array of Strings. Arguments passed to command.

For more information about meaning of the fields consult master (5) manual: http://www.postfix.org/master.5.html

Recipes

default

Installs the postfix package and manages the service and the main configuration files (/etc/postfix/main.cf and /etc/postfix/master.cf). See Usage and Examples to see how to affect behavior of this recipe through configuration. Depending on the node['postfix']['use_alias_maps'], node['postfix']['use_transport_maps'], node['postfix']['use_access_maps'] and node['postfix']['use_virtual_aliases'] attributes the default recipe can call additional recipes to manage additional postfix configuration files

For a more dynamic approach to discovery for the relayhost, see the client and server recipes below.

client

Use this recipe to have nodes automatically search for the mail relay based which node has the node['postfix']['relayhost_role'] role. Sets the node['postfix']['main']['relayhost'] attribute to the first result from the search.

Includes the default recipe to install, configure and start postfix.

Does not work with chef-solo.

sasl_auth

Sets up the system to authenticate with a remote mail relay using SASL authentication.

server

To use Chef Server search to automatically detect a node that is the relayhost, use this recipe in a role that will be relayhost. By default, the role should be "relayhost" but you can change the attribute node['postfix']['relayhost_role'] to modify this.

Note This recipe will set the node['postfix']['mail_type'] to "master" with an override attribute.

maps

General recipe to manage any number of any type postfix lookup tables. You can replace with it recipes like transport or virtual_aliases, but what is more important - you can create any kinds of maps, which has no own recipe, including database lookup maps configuration. maps is a hash keys of which is a lookup table type and value is another hash with filenames as the keys and hash with file content as the value. File content is an any number of key/value pairs which meaning depends on lookup table type. Examlle:

  "override_attributes": {
    "postfix": {
      "maps": {
        "hash": {
          "/etc/postfix/vmailbox": {
            "[email protected]": "ok",
            "[email protected]": "ok",
          },
          "/etc/postfix/virtual": {
            "[email protected]": "[email protected]",
            "[email protected]": "[email protected]",
            "[email protected]": "[email protected]"
          },
          "/etc/postfix/envelope_senders": {
            "@example.com": "[email protected]",
            "@example.net": "[email protected]"
          },
          "/etc/postfix/relay_recipients": {
            "[email protected]": "ok",
            "[email protected]": "ok",
            "[email protected]": "ok",
          }
       },
       "pgsql": {
          "/etc/postfix/pgtest": {
            "hosts": "db.local:2345",
            "user": "postfix",
            "password": "test",
            "dbname": "postdb",
            "query": "SELECT replacement FROM aliases WHERE mailbox = '%s'"
          }
        }
     }
  }

To use these files in your configuration reference them in node['postfix']['main'], for instance:

    "postfix": {
      "main": {
        "smtpd_sender_login_maps": "hash:/etc/postfix/envelope_senders",
        "relay_recipient_maps": "hash:/etc/postfix/relay_recipients",
        "virtual_mailbox_maps": "hash:/etc/postfix/vmailbox",
        "virtual_alias_maps": "hash:/etc/postfix/virtual",
      }
    }

aliases

Manage /etc/aliases with this recipe. Currently only Ubuntu 10.04 platform has a template for the aliases file. Add your aliases template to the templates/default or to the appropriate platform+version directory per the File Specificity rules for templates. Then specify a hash of aliases for the node['postfix']['aliases'] attribute.

Arrays are supported as alias values, since postfix supports comma separated values per alias, simply specify your alias as an array to use this handy feature.

aliases

Manage /etc/aliases with this recipe.

transports

Manage /etc/postfix/transport with this recipe.

access

Manage /etc/postfix/access with this recipe.

virtual_aliases

Manage /etc/postfix/virtual with this recipe.

relay_restrictions

Manage /etc/postfix/relay_restriction with this recipe The postfix option smtpd_relay_restrictions in main.cf will point to this hash map db.

http://wiki.chef.io/display/chef/Templates#Templates-TemplateLocationSpecificity

Usage

On systems that should simply send mail directly to a relay, or out to the internet, use recipe[postfix] and modify the node['postfix']['main']['relayhost'] attribute via a role.

On systems that should be the MX for a domain, set the attributes accordingly and make sure the node['postfix']['mail_type'] attribute is master. See Examples for information on how to use recipe[postfix::server] to do this automatically.

If you need to use SASL authentication to send mail through your ISP (such as on a home network), use postfix::sasl_auth and set the appropriate attributes.

For each of these implementations, see Examples for role usage.

Examples

The example roles below only have the relevant postfix usage. You may have other contents depending on what you're configuring on your systems.

The base role is applied to all nodes in the environment.

name "base"
run_list("recipe[postfix]")
override_attributes(
  "postfix" => {
    "mail_type" => "client",
    "main" => {
      "mydomain" => "example.com",
      "myorigin" => "example.com",
      "relayhost" => "[smtp.example.com]",
      "smtp_use_tls" => "no"
    }
  }
)

The relayhost role is applied to the nodes that are relayhosts. Often this is 2 systems using a CNAME of smtp.example.com.

name "relayhost"
run_list("recipe[postfix::server]")
override_attributes(
  "postfix" => {
    "mail_type" => "master",
    "main" => {
      "mynetworks" => [ "10.3.3.0/24", "127.0.0.0/8" ],
      "inet_interfaces" => "all",
      "mydomain" => "example.com",
      "myorigin" => "example.com"
  }
)

The sasl_relayhost role is applied to the nodes that are relayhosts and require authenticating with SASL. For example this might be on a household network with an ISP that otherwise blocks direct internet access to SMTP.

name "sasl_relayhost"
run_list("recipe[postfix], recipe[postfix::sasl_auth]")
override_attributes(
  "postfix" => {
    "mail_type" => "master",
    "main" => {
      "mynetworks" => "10.3.3.0/24",
      "mydomain" => "example.com",
      "myorigin" => "example.com",
      "relayhost" => "[smtp.comcast.net]:587",
      "smtp_sasl_auth_enable" => "yes"
    },
    "sasl" => {
      "relayhost1" => {
        "username" => "your_password",
        "password" => "your_username"
      },
      "relayhost2" => {
        ...
      },
      ...
    }
  }
)

For an example of using encrypted data bags to encrypt the SASL password, see the following blog post:

Examples using the client & server recipes

If you'd like to use the more dynamic search based approach for discovery, use the server and client recipes. First, create a relayhost role.

name "relayhost"
run_list("recipe[postfix::server]")
override_attributes(
  "postfix" => {
    "main" => {
      "mynetworks" => "10.3.3.0/24",
      "mydomain" => "example.com",
      "myorigin" => "example.com"
    }
  }
)

Then, add the postfix::client recipe to the run list of your base role or equivalent role for postfix clients.

name "base"
run_list("recipe[postfix::client]")
override_attributes(
  "postfix" => {
    "mail_type" => "client",
    "main" => {
      "mydomain" => "example.com",
      "myorigin" => "example.com"
    }
  }
)

If you wish to use a different role name for the relayhost, then also set the attribute in the base role. For example, postfix_master as the role name:

name "postfix_master"
description "a role for postfix master that isn't relayhost"
run_list("recipe[postfix::server]")
override_attributes(
  "postfix" => {
    "main" => {
      "mynetworks" => "10.3.3.0/24",
      "mydomain" => "example.com",
      "myorigin" => "example.com"
    }
  }
)

The base role would look something like this:

name "base"
run_list("recipe[postfix::client]")
override_attributes(
  "postfix" => {
    "relayhost_role" => "postfix_master",
    "mail_type" => "client",
    "main" => {
      "mydomain" => "example.com",
      "myorigin" => "example.com"
    }
  }
)

To use relay restrictions override the relay restrictions attribute in this format:

override_attributes(
  "postfix" => {
    "use_relay_restrictions_maps" => true,
    "relay_restrictions" => {
      "chef.io" => "OK",
      ".chef.io" => "OK",
      "example.com" => "OK"
    }
  }
)

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

postfix's People

Contributors

arr-dev avatar chasebolt avatar damacus avatar djoos avatar iennae avatar jeremiahsnapp avatar justatrick avatar kitchen-porter avatar kochalex avatar lamont-granquist avatar maoueh avatar mawatech avatar mcornick avatar mvangoor avatar nathenharvey avatar palfrey avatar pfuender avatar ramereth avatar renovate[bot] avatar rhass avatar sawanoboly avatar sethvargo avatar smith avatar stevendanna avatar tas50 avatar themoore avatar trobrock avatar voroniys avatar xorima avatar xorimabot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postfix's Issues

postfix tls problem

I keep getting this error when connecting to postfix from nodemailer:
Error: Error upgrading connection with STARTTLS: 454 4.7.0 TLS not available due to local problem

However, there is no problem connecting and sending email with email client. Also diagnostic tools show no tls errors - all seems fine. The only thing I notice is that diagnostics report tls v 1.2 while the error mentiones 4.7.0 TLS. Is this a version number?

I would appreciate someone to help me with this issue.

Hostname should be included on default value of mydestination

default['postfix']['main']['mydestination'] = [node['postfix']['main']['myhostname'], node['hostname'], 'localhost.localdomain', 'localhost'].compact

This makes delivery fails to node['postfix']['main']['myhostname'] and node['hostname'] if the receiver server is at another host.

This also makes override complicated as it can't be done on roles, just directly on node attributes.

I can make a pull request if you agree.

Extra single quote for "Relayhost's role" in metadata.rb breaks Berkshelf upload.

When using Berkshelf 0.3.0, and Berkshelf 0.2.0 on CentOS 6, the resulting metadata.json is broken. Uploads that rely purely on 'metadata.rb' seem to work well, and the issue generating metadata.json seems to be the embedded single quote in the phrase "Relayhost's role".

Even if the single quote isn't the issue, embedding quotes inside quoted text is asking for trouble in the future. This one is also not syntactically necessary.

SASL packages are hard coded

In order to have a clean installation of packages and preventing spreading installation logic in multiple places, it's good idea to add an option regarding additional sasl_packages.

Cookbook Version

5.3.1

Scenario

I want to install cyrus-sasl-md5 as part of postfix installation.

Expected Result

I add cyrus-sasl-md5 to default['postfix']['sasl_packages'] and it gets installed.

Actual Result

There is no way to add additional packages through the cookbook.

Custom Resource

It would be nice if the cookbook supported custom resources (chef >=12.5). Any plans to refactor to custom resources?

Recipe Compile Error in /tmp/chef/cookbooks/postfix/recipes/sasl_auth.rb

By default, the recipe doesn't work unless you override attributes to enable smtp_sasl_auth_enable => 'yes'

Recipe Compile Error in /tmp/chef/cookbooks/postfix/recipes/sasl_auth.rb
================================================================================


ArgumentError
-------------
You must supply a name when declaring a template resource


Cookbook Trace:
---------------
  /tmp/chef/cookbooks/postfix/recipes/sasl_auth.rb:51:in `from_file'


Relevant File Content:
----------------------
/tmp/chef/cookbooks/postfix/recipes/sasl_auth.rb:

 44:  
 45:  execute 'postmap-sasl_passwd' do
 46:    command "postmap #{node['postfix']['sasl_password_file']}"
 47:    environment 'PATH' => "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
 48:    action :nothing
 49:  end
 50:  
 51>> template node['postfix']['sasl_password_file'] do
 52:    source 'sasl_passwd.erb'
 53:    owner 'root'
 54:    group 'root'
 55:    mode 0400
 56:    notifies :run, 'execute[postmap-sasl_passwd]', :immediately
 57:    notifies :restart, 'service[postfix]'
 58:    variables(settings: node['postfix']['sasl'])
 59:  end
 60:  

This is likely due to the conditional configuration of sasl_password_file

if node['postfix']['main']['smtp_sasl_auth_enable'] == 'yes'
  default['postfix']['sasl_password_file'] = "#{node['postfix']['conf_dir']}/sasl_passwd"
  default['postfix']['main']['smtp_sasl_password_maps'] = "hash:#{node['postfix']['sasl_password_file']}"
  default['postfix']['main']['smtp_sasl_security_options'] = 'noanonymous'
  default['postfix']['sasl']['smtp_sasl_user_name'] = ''
  default['postfix']['sasl']['smtp_sasl_passwd']    = ''
  default['postfix']['main']['relayhost'] = ''
end

Transports recipe references missing template

Chef::Exceptions::FileNotFound
------------------------------
Cookbook 'postfix' (3.3.1) does not contain a file at any of these locations:
  templates/ubuntu-12.04/transport.erb
  templates/ubuntu/transport.erb
  templates/default/transport.erb

There is a typo in the transports recipe making the transports recipe broken. The template should be "transports"

This bug means the transports recipe can't be included as a work around for #69

Documentation error on readme: inet-interfaces

The documentation on the readme describes how to create a role for a relayhost, and defines the override attributes as part of that role. One of those overrides lists "inet-interfaces" => "all". This option in postfix should use an underscore, not a dash.

Directly copy/pasting this role, without fixing the typo, results in:

grep interfaces /etc/postfix/main.cf
inet-interfaces = all
inet_interfaces = loopback-only

Unused Parameter in main.cf

In version 3.4.0 the following non-default parameters were inserted in attributes/default.rb:

Non-default main.cf attributes

default['postfix']['main']['use_alias_maps'] = 'no'
default['postfix']['main']['use_transport_maps'] = 'no'
default['postfix']['main']['use_access_maps'] = 'no'
default['postfix']['main']['use_virtual_aliases'] = 'no'

When restarting the postfix-service I will get the following warnings

sudo service postfix restart

  • Stopping Postfix Mail Transport Agent postfix
    /usr/sbin/postconf: warning: /etc/postfix/main.cf: unused parameter: use_virtual_aliases=no
    /usr/sbin/postconf: warning: /etc/postfix/main.cf: unused parameter: use_transport_maps=no
    /usr/sbin/postconf: warning: /etc/postfix/main.cf: unused parameter: use_alias_maps=no
    /usr/sbin/postconf: warning: /etc/postfix/main.cf: unused parameter: use_access_maps=no
  • Starting Postfix Mail Transport Agent postfix
    postconf: warning: /etc/postfix/main.cf: unused parameter: use_virtual_aliases=no
    postconf: warning: /etc/postfix/main.cf: unused parameter: use_transport_maps=no
    postconf: warning: /etc/postfix/main.cf: unused parameter: use_alias_maps=no
    postconf: warning: /etc/postfix/main.cf: unused parameter: use_access_maps=no
    postconf: warning: /etc/postfix/main.cf: unused parameter: use_virtual_aliases=no
    ...

I don't find any explanation on postfix documentation about these parameters. Why are these parameters inserted?

`use_relay_restrictions_maps` makes converge fail

(Continuing on from #135)

Cookbook version

5.0.2

Chef-client version

13.0.118

Platform Details

Debian 8.4, Scaleway x64

Scenario:

Use relay restrictions

Steps to Reproduce:

  1. Set attribute override["postfix"]["use_relay_restrictions_maps"] = true
  2. Use recipe postfix::server

Expected Result:

Working converge

Actual Result:

NameError
  ---------
  undefined local variable or method `default' for cookbook: postfix, recipe: _attributes :Chef::Recipe

  Cookbook Trace:
  ---------------
    /website/config/local-mode-cache/cache/cookbooks/postfix/recipes/_attributes.rb:62:in `from_file'
    /website/config/local-mode-cache/cache/cookbooks/postfix/recipes/_common.rb:20:in `from_file'
    /website/config/local-mode-cache/cache/cookbooks/postfix/recipes/default.rb:20:in `from_file'
    /website/config/local-mode-cache/cache/cookbooks/postfix/recipes/server.rb:24:in `from_file'
    /website/config/local-mode-cache/cache/cookbooks/website/recipes/email.rb:1:in `from_file'
    /website/config/local-mode-cache/cache/cookbooks/website/recipes/default.rb:13:in `from_file'

  Relevant File Content:
  ----------------------
  /website/config/local-mode-cache/cache/cookbooks/postfix/recipes/_attributes.rb:

   55:  end
   56:
   57:  if node['postfix']['use_virtual_aliases_domains']
   58:    node.default_unless['postfix']['main']['virtual_alias_domains'] = ["#{node['postfix']['virtual_alias_domains_db_type']}:#{node['postfix']['virtual_alias_domains_db']}"]
   59:  end
   60:
   61:  if node['postfix']['use_relay_restrictions_maps']
   62>>   default['postfix']['main']['smtpd_relay_restrictions'] = "hash:#{node['postfix']['relay_restrictions_db']}, reject"
   63:  end
   64:
   65:  if node['postfix']['master']['maildrop']['active']
   66:    node.default_unless['postfix']['main']['maildrop_destination_recipient_limit'] = 1
   67:  end
   68:
   69:  if node['postfix']['master']['cyrus']['active']
   70:    node.default_unless['postfix']['main']['cyrus_destination_recipient_limit'] = 1
   71:  end

transport.db is missing

Regarding #66 - added configuration transport support. On my system running previous version of this cookbook after upgrade the transport.db is not being created - thus mail handling fails.

Please add template resource to create it or do not put it in the main.cf.

Jun 13 10:45:07 ops postfix/trivial-rewrite[2101]: warning: hash:/etc/postfix/transport is unavailable. open database /etc/postfix/transport.db: No such file or directory

"use_relay_restrictions_maps" misspelt in recipes

Using version: 5.0.1

use_relay_restrictions_maps is misspelt at the bottom of attributes/default.rb as use_relay_restirictions_maps (note the extra i after the first t). There's a similar problem in recipes/_attributes.rb which masks an issue in the use of default not node.default_unless as well.

Using this cookbook to provision docker containers fails when attempting to do the service start/restart

Cookbook version

5.3.1

Chef-client version

[Version of chef-client in your environment]

Platform Details

ubuntu 14.04, ubuntu 16.04, centos 7

Scenario:

Trying to use this cookbook to provision a docker container fails when the cookbook attempts to start the postfix service, as most containers don't have functioning upstart/systemd/whatever. This does pass on centos 6, but I imagine it has to do with the way those containers are set up.

Steps to Reproduce:

Attempt to provision a docker container with this cookbook by using docker kitchen or similar.

Proposed solution:

Allowing for the actual enabling/restart/start of the service to be conditionally triggered so that it would be possible to disable the behavior when provisioning a container.

Postfix not reloaded/restarted after postmap resource for virtual aliases; causes mail delivery problems

Cookbook version

5.3.1

Chef-client version

13.8.5

Platform Details

This was tested on a CentOS 7.6 image generated using this packer template:
https://github.com/osuosl/packer-templates/blob/74319bd787682e71ee3b2abd371ce0464ef75fed/centos-7-x86_64-openstack.json

(Though you should be able to reproduce with any CentOS 7 image, and I would be surprised if not other platforms too.)

Scenario:

I've noticed that during the first Chef run deploying/configuring postfix, when using virtual aliases the virtual alias DB will be generated via postmap but the cookbook does not appear to reload or restart postfix afterwards. When I send a test email, it generates warnings about not being able to use virtual.db, but this is corrected after reloading postfix.

I think the notification/resource ordering in the virtual_aliases recipe should be tweaked so that virtual aliases are useable after the first/single Chef run.

Steps to Reproduce:

The following steps will help to visualize that postfix is not reloaded or restarted after generating the virtual aliases db:

  1. Add a test suite to kitchen.yml for postfix::virtual_aliases recipe:
- name: virtual_aliases
  run_list:
  - recipe[postfix::virtual_aliases]
  1. Converge the test suite (in this example using CentOS 7): kitchen converge virtual-aliases-centos-7

  2. Examine kitchen's output. Note that after the execute[update-postfix-virtual-alias] resource there is no reloading or restarting of the postfix service.

Expected Result:

I expected postfix to successfully deliver mail that relies on virtual aliases after a single Chef run deploying/configuring postfix. More specifically, I expect postfix to be reloaded or restarted after the resource running postmap occurs.

Actual Result:

Postfix defers delivery on mail that relies on the virtual aliases after a single Chef run deploying/configuring postfix. This is what I see in mail logs indicating the problem:

Jan 24 21:38:39 authsqlcentos7-whitehet-turquoise-sslh1vv postfix/cleanup[20485]: warning: hash:/etc/postfix/virtual is unavailable. open database /etc/postfix/virtual.db: No such file or directory
Jan 24 21:38:39 authsqlcentos7-whitehet-turquoise-sslh1vv postfix/cleanup[20485]: warning: hash:/etc/postfix/virtual lookup error for "[email protected]"
Jan 24 21:38:39 authsqlcentos7-whitehet-turquoise-sslh1vv postfix/cleanup[20485]: warning: 6318F2129A: virtual_alias_maps map lookup problem for [email protected] -- deferring delivery

I can achieve the expected result by reloading postfix inside the kitchen VM and converging again, which allows the email to be delivered successfully, so I think the resource/notify ordering of postfix::virtual_aliases may need tweaking to ensure there's a reload or restart after postmap.

New release to supermarket

The 5.2.0 version was released on Aug 7, 2017 according to the Changelog but it does not appear to have been pushed to the supermarket.

Any chance that the current version can be pushed to the supermarket for use?

postfix 3.3.0 and a relayhost

Cookbook version

5.3.0

Chef-client version

14

Platform Details

ubuntu 18.04

Scenario:

I configured a relayhost, but since postfix 3.3.0 you need to specify smtpd_recipient_restrictions

Steps to Reproduce:

Configure a relayhost on ubuntu 18.04, and you will see this error in the log:

Jul 16 11:53:38 testvm-postfix postfix/smtpd[16498]: fatal: in parameter smtpd_relay_restrictions or smtpd_recipient_restrictions, specify at least one working instance of: reject_unauth_destination, defer_unauth_destination, reject, defer, defer_if_permit or check_relay_domains

Expected Result:

it should allow you to send a mail through the relayhost

Actual Result:

postfix is not available on port 25

Extra question

I could make a MR, but i'm not sure what direction i should use.

Do i check the postfix version? If it's > 3.3.0 then add an extra line in the main.cf?
Do i configure a default smtpd_recipient_restrictions, if nothing is provided?
i.e. smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination, reject

Cookbook does not ensure presence of postfix table dbs

During testing of a wrapper cookbook, we very quickly noticed that if the .db files corresponding to a postfix table are deleted, they are not replaced unless the content of the table file is changed, which triggers execution of postmap again.

Obviously, nothing should be deleting these files but this makes it really difficult to ensure consistency of the state declared by the cookbook.

There's a simple fix - in the recipes for the various files, like transport.rb, instead of:

execute 'update-postfix-transport' do
  command "postmap #{node['postfix']['transport_db']}"
  environment PATH: "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
  action :nothing
end

It could be:

execute 'update-postfix-transport' do
  command "postmap #{node['postfix']['transport_db']}"
  environment PATH: "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
  action File.exist?("#{node['postfix']['transport_db'].db") ? :nothing : :run
end

Which maintains all the current behavior but also runs postmap if the db file is missing.

Thanks

Not able to set 'smtp_generic_map_entries' in postfix

Cookbook version

[5.3.1]

Chef-client version

[12.6.0]

Platform Details

[CentOs 7.3]

Scenario:

Trying to install postfix 2.10.1-6.el7 and change outgoing SMTP email( trying to use smtp_generic_map_etries)

Steps to Reproduce:

Berksfile

source 'https://api.berkshelf.com'
metadata
cookbook 'postfix'

.kitchen.yml

---
driver:
  name: vagrant

provisioner:
  name: chef_solo
  require_chef_omnibus: 12.6.0
  roles_path: "test/integration/roles"

platforms:
  - name: centos-7.3

suites:
  - name: mail-postfix
    run_list:
      - recipe[install_postfix]

attributes/postfix.rb

override['postfix']['main'] = {
  'inet_protocols'     => 'ipv4',
  'relayhost'          => 'mail.ops.example.net',
  'mydomain'           => 'example.net',
  'myorigin'           => 'example.net'
}
override['postfix']['smtp_generic_map_entries'] = { 
	"[email protected]" => "[email protected]", 
	"[email protected]" => "[email protected]" 
}

recipe/postfix.rb

package 'postfix' do
  action [:install, :upgrade]
  version '2.10.1-6.el7'
end

running kitchen-test converge should install postfix on vagrant.

Expected Result:

  1. It should create /etc/postfix/generic file with '[email protected]' 2. '[email protected]' entries along with smtp_generic_maps = hash:/etc/postfix/generic in main.cf

Actual Result:

  1. /etc/postfix/generic is default with no changes
  2. no smtp_generic_maps = hash:/etc/postfix/generic in main.cf

Request: Ability to disable ipv6

Cookbook version

Latest

Chef-client version

Latest

Platform Details

CentOS 7

Scenario:

Unless I'm missing something (which is possible and apologies if so) but it seems like I can't disable ipv6. Note from the man page below ipv6 is always used first but our SMTP server is running ipv4 only so I'd like to force it to only use ipv4 using the inet_protocols directive as below.

Thanks.

postconf(5)

 man page:

When IPv6 support is enabled via the inet_protocols parameter,  Post-
fix will do DNS type AAAA record lookups.

When  both IPv4 and IPv6 support are enabled, the Postfix SMTP client
will attempt to connect via IPv6 before attempting to use IPv4.

Examples:

inet_protocols = ipv4
inet_protocols = all (DEFAULT)
inet_protocols = ipv6
inet_protocols = ipv4, ipv6

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/stale.yml
  • actions/stale v9

  • Check this box to trigger a request for Renovate to run again on this repository

Server restart errors not raised

If you put a value into node[:postfix][:main][:invalid_key] no server restart will raise. I had tested the restart with sudo service postfix restart and saw the error.

Any reason for no metadata.rb?

Cookbook version

4.0.0

Chef-client version

12.14.89

Platform Details

Running the cookbook under test kitchen.

Scenario:

metadata.rb is missing, no big deal just wondering why?

Steps to Reproduce:

Need to write your own metadata.rb to use with test kitchen.

Expected Result:

Expected a metadata.rb file.

Actual Result:

Need to write your own metadata.rb to use with test kitchen.

Build failing on master?

Howdy. Sorry for the leechy user question. The master branch has been failing to build (on FoodCritic via Travis) for 13 days. I'd love to make use of this cookbook, but is there a "successful" build I can use, perhaps that pre-dates this failing on? Thanks in advance!

Jesse

Adding full mailaddress as alias-target is not working

Cookbook version

Latest

Chef-client version

Latest

Platform Details

Debian 8

Scenario:

Adding a full emailaddress ([email protected]) to the postfix aliases doesn't
work. The template (aliases.rb) keeps adding double-quotes around it, whereas
postfix then doesn't recognize the domain-part and threats it as a local
address. The manpage (http://www.postfix.org/aliases.5.html) doesn't state that
an "address" needs to be quoted. But once an address is quoted, postfix will
append the domain and send mails to "[email protected]"@company.com - which
obviously doesn't work.

Can anyone else confirm this behaviour?

Steps to Reproduce:

node.override['postfix']['aliases'] = { "www" => "[email protected]" }

Expected Result:

$ cat www /etc/aliases

#
# This file is generated by Chef
#
# (...)
www: [email protected]

Actual Result:

$ cat www /etc/aliases

#
# This file is generated by Chef
#
# (...)
www: "[email protected]"

sasl passwd problems with 5.3.0

Cookbook version

5.3.0

Chef-client version

12.20.3

Platform Details

Red Hat Enterprise Linux Server release 7.5 (Maipo) on AWS

Scenario:

smtp relay host via SES with sasl uesrname & password

Steps to Reproduce:

I had been using this for awhile in my attributes:

default["postfix"]["main"]["relayhost"] = "email-smtp.us-east-1.amazonaws.com:587"
default["postfix"]["main"]["smtp_sasl_auth_enable"] = "yes"
default["postfix"]["main"]["smtpd_use_tls"] = "no"
default["postfix"]["sasl"]["smtp_sasl_user_name"] = "<snip>"
default["postfix"]["sasl"]["smtp_sasl_passwd"] = "<snip>"

Expected Result:

Previously, this seemed to result in:

default["postfix"]["main"]["relayhost"] = "email-smtp.us-east-1.amazonaws.com:587"
default["postfix"]["main"]["smtp_sasl_auth_enable"] = "yes"
default["postfix"]["main"]["smtpd_use_tls"] = "no"
default["postfix"]["sasl"]["smtp_sasl_user_name"] = "<snip>"
default["postfix"]["sasl"]["smtp_sasl_passwd"] = "<snip>"


$ cat /etc/postfix/sasl_passwd
# Auto-generated by Chef.
# Local modifications will be overwritten.
#
email-smtp.us-east-1.amazonaws.com:587 <snip>:<snip>

Actual Result:

Now with 5.3.0 I ended up with:

$ cat /etc/postfix/sasl_passwd
# Auto-generated by Chef.
# Local modifications will be overwritten.

smtp_sasl_passwd :
smtp_sasl_user_name :

I was able to resolve it by changing the attributes:

default["postfix"]["sasl"] = {
	"email-smtp.us-east-1.amazonaws.com:587" => {
		"username" => "<snip>",
		"password" => "<snip>"
	}
}

It seems like it was a breaking change with a minor version bump though

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.