Merge pull request #3 from skylerberg/master

Adds config state
This commit is contained in:
Daniel Wallace 2014-08-21 19:16:59 -05:00
commit 9235b882c0
6 changed files with 136 additions and 60 deletions

View file

@ -1,7 +1,26 @@
postfix postfix
======= =======
postfix Formulas to set up and configure the Postfix mail transfer agent.
-------
Install and start postfix .. note::
See the full `Salt Formulas installation and usage instructions
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.
Available states
================
.. contents::
:local:
``postfix``
-----------
Installs and starts postfix SMTP server
``postfix.config``
------------------
Manages postfix main.cf configuration file

View file

@ -0,0 +1,23 @@
postfix:
smtpd_banner: $myhostname ESMTP $mail_name
biff: "'no'"
append_dot_mydomain: "'no'"
readme_directory: "'no'"
smtpd_tls_cert_file: /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file: /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls: "'yes'"
smtpd_tls_session_cache_database: btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database: btree:${data_directory}/smtp_scache
myhostname: {{ grains['fqdn'] }}
alias_maps: hash:/etc/aliases
alias_database: hash:/etc/aliases
mydestination: {{ grains['fqdn'] }}, localhost.localdomain, {{ grains['domain'] }}
relayhost:
mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit: 0
recipient_delimiter: +
inet_interfaces: all

45
postfix/config.sls Normal file
View file

@ -0,0 +1,45 @@
include:
- postfix
/etc/postfix:
file.directory:
- user: root
- group: root
- dir_mode: 755
- file_mode: 644
- makedirs: True
/etc/postfix/main.cf:
file.managed:
- source: salt://postfix/files/main.cf
- user: root
- group: root
- mode: 644
- require:
- pkg: postfix
- watch_in:
- service: postfix
- template: jinja
- defaults:
smtpd_banner: {{ salt['pillar.get']('postfix:smtpd_banner', '$myhostname ESMTP $mail_name' )}}
biff: {{ salt['pillar.get']('postfix:biff', "'no'" )}}
append_dot_mydomain: {{ salt['pillar.get']('postfix:append_dot_mydomain', "'no'" )}}
readme_directory: {{ salt['pillar.get']('postfix:readme_directory', "'no'" )}}
smtpd_tls_cert_file: {{ salt['pillar.get']('postfix:smtpd_tls_cert_file', '/etc/ssl/certs/ssl-cert-snakeoil.pem' )}}
smtpd_tls_key_file: {{ salt['pillar.get']('postfix:smtpd_tls_key_file', '/etc/ssl/private/ssl-cert-snakeoil.key' )}}
smtpd_use_tls: {{ salt['pillar.get']('postfix:smtpd_use_tls', "'yes'" )}}
smtpd_tls_session_cache_database: {{ salt['pillar.get']('postfix:smtpd_tls_session_cache_database', 'btree:${data_directory}/smtpd_scache' )}}
smtp_tls_session_cache_database: {{ salt['pillar.get']('postfix:smtp_tls_session_cache_database', 'btree:${data_directory}/smtp_scache' )}}
myhostname: {{ salt['pillar.get']('postfix:myhostname', grains['fqdn'] )}}
alias_maps: {{ salt['pillar.get']('postfix:alias_maps', 'hash:/etc/aliases' )}}
alias_database: {{ salt['pillar.get']('postfix:alias_database', 'hash:/etc/aliases' )}}
mydestination: {{ salt['pillar.get']('postfix:mydestination', grains['fqdn'] + ', localhost.localdomain, ' + grains['domain'] )}}
relayhost: {{ salt['pillar.get']('postfix:relayhost', '' )}}
mynetworks: {{ salt['pillar.get']('postfix:mynetworks', '127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128' )}}
mailbox_size_limit: {{ salt['pillar.get']('postfix:mailbox_size_limit', '0' )}}
recipient_delimiter: {{ salt['pillar.get']('postfix:recipient_delimiter', '+' )}}
inet_interfaces: {{ salt['pillar.get']('postfix:inet_interfaces', 'all' )}}

46
postfix/files/main.cf Normal file
View file

@ -0,0 +1,46 @@
# Managed by config management
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = {{ smtpd_banner }}
biff = {{ biff }}
# appending .domain is the MUA's job.
append_dot_mydomain = {{ append_dot_mydomain }}
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = {{ readme_directory }}
# TLS parameters
smtpd_tls_cert_file = {{ smtpd_tls_cert_file }}
smtpd_tls_key_file = {{ smtpd_tls_key_file }}
smtpd_use_tls = {{ smtpd_use_tls }}
smtpd_tls_session_cache_database = {{ smtpd_tls_session_cache_database }}
smtp_tls_session_cache_database = {{ smtp_tls_session_cache_database }}
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = {{ myhostname }}
alias_maps = {{ alias_maps }}
alias_database = {{ alias_database }}
mydestination = {{ mydestination }}
relayhost = {{ relayhost }}
mynetworks = {{ mynetworks }}
mailbox_size_limit = {{ mailbox_size_limit }}
recipient_delimiter = {{ recipient_delimiter }}
inet_interfaces = {{ inet_interfaces }}
{% if 'virtual' in pillar.get('postfix','') %}
virtual_alias_maps = hash:/etc/postfix/virtual
{% endif %}
#TODO: move into a pillar
message_size_limit = 41943040

View file

@ -7,18 +7,6 @@ postfix:
- pkg: postfix - pkg: postfix
- watch: - watch:
- pkg: postfix - pkg: postfix
- file: /etc/postfix/main.cf
# postfix main configuration file
/etc/postfix/main.cf:
file.managed:
- source: salt://postfix/main.cf
- user: root
- group: root
- mode: 644
- template: jinja
- require:
- pkg: postfix
# manage /etc/aliases if data found in pillar # manage /etc/aliases if data found in pillar
{% if 'aliases' in pillar.get('postfix', '') %} {% if 'aliases' in pillar.get('postfix', '') %}

View file

@ -1,45 +0,0 @@
# Managed by config management
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = {{ grains['fqdn'] }}
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = {{ grains['fqdn'] }}, localhost, {{ grains['domain'] }}
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
{% if 'virtual' in pillar.get('postfix','') %}
virtual_alias_maps = hash:/etc/postfix/virtual
{% endif %}
#TODO: move into a pillar
message_size_limit = 41943040