Merge pull request #28 from jbeigh/master

enable smtp_sasl_password_maps: hash:/etc/postfix/sasl_password
This commit is contained in:
Forrest 2015-09-02 15:49:52 -07:00
commit f488c404eb
4 changed files with 34 additions and 1 deletions

View file

@ -9,6 +9,9 @@ postfix:
- someuser_2@example.com - someuser_2@example.com
singlealiasexample: 'someuser_3@example.com' singlealiasexample: 'someuser_3@example.com'
sasl_passwd:
smtp.example.com: 'somepassword'
sender_canonical: sender_canonical:
root: 'servers@example.com' root: 'servers@example.com'
nagios: 'alerts@example.com' nagios: 'alerts@example.com'

View file

@ -1,6 +1,6 @@
{%- from "postfix/map.jinja" import postfix with context -%} {%- from "postfix/map.jinja" import postfix with context -%}
{%- set config = salt['pillar.get']('postfix:config', {}) -%} {%- set config = salt['pillar.get']('postfix:config', {}) -%}
{% set processed_parameters = ['aliases_file', 'virtual', 'sender_canonical'] %} {% set processed_parameters = ['aliases_file', 'virtual', 'sasl_passwd', 'sender_canonical'] %}
{%- macro set_parameter(parameter, default=None) -%} {%- macro set_parameter(parameter, default=None) -%}
{% set value = config.get(parameter, default) %} {% set value = config.get(parameter, default) %}
{%- if value is not none %} {%- if value is not none %}
@ -103,6 +103,10 @@ policy-spf_time_limit = {{ policyd_spf.get('time_limit', '3600s') }}
virtual_alias_maps = hash:/etc/postfix/virtual virtual_alias_maps = hash:/etc/postfix/virtual
{% endif %} {% endif %}
{% if 'sasl_passwd' in pillar.get('postfix','') %}
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
{% endif %}
{% if 'sender_canonical' in pillar.get('postfix','') %} {% if 'sender_canonical' in pillar.get('postfix','') %}
sender_canonical_maps = hash:/etc/postfix/sender_canonical sender_canonical_maps = hash:/etc/postfix/sender_canonical
{% endif %} {% endif %}

View file

@ -52,6 +52,25 @@ run-postmap:
- file: /etc/postfix/virtual - file: /etc/postfix/virtual
{% endif %} {% endif %}
# manage /etc/postfix/sasl_passwd if data found in pillar
{% if 'sasl_passwd' in pillar.get('postfix', '') %}
/etc/postfix/sasl_passwd:
file.managed:
- source: salt://postfix/sasl_passwd
- user: root
- group: root
- mode: 644
- template: jinja
- require:
- pkg: postfix
cmd.wait:
- name: /usr/sbin/postmap /etc/postfix/sasl_passwd
- cwd: /
- watch:
- file: /etc/postfix/sasl_passwd
{% endif %}
# manage /etc/postfix/sender_canonical if data found in pillar # manage /etc/postfix/sender_canonical if data found in pillar
{% if 'sender_canonical' in pillar.get('postfix', '') %} {% if 'sender_canonical' in pillar.get('postfix', '') %}
/etc/postfix/sender_canonical: /etc/postfix/sender_canonical:

7
postfix/sasl_passwd Normal file
View file

@ -0,0 +1,7 @@
# Managed by config management
{% set canonical = salt['pillar.get']('postfix:sasl_passwd',{}) -%}
{% if canonical is iterable -%}
{% for key,value in salt['pillar.get']('postfix:sasl_passwd',{}).iteritems() -%}
{{ key }} {{ value }}
{% endfor %}
{% endif %}