2015-02-26 10:19:08 -05:00
|
|
|
{% from "postfix/map.jinja" import postfix with context %}
|
|
|
|
|
2013-06-13 01:55:32 -04:00
|
|
|
postfix:
|
2015-02-26 10:19:08 -05:00
|
|
|
pkg.installed:
|
2015-08-22 06:46:35 -04:00
|
|
|
- name: {{ postfix.package }}
|
2015-02-26 10:19:08 -05:00
|
|
|
- watch_in:
|
|
|
|
- service: postfix
|
2013-06-13 01:55:32 -04:00
|
|
|
service.running:
|
2016-05-18 13:29:37 -04:00
|
|
|
- enable: {{ salt['pillar.get']('postfix:enable_service', True) }}
|
2013-06-13 01:55:32 -04:00
|
|
|
- require:
|
|
|
|
- pkg: postfix
|
2014-04-23 15:02:09 -04:00
|
|
|
- watch:
|
|
|
|
- pkg: postfix
|
|
|
|
|
|
|
|
# manage /etc/aliases if data found in pillar
|
|
|
|
{% if 'aliases' in pillar.get('postfix', '') %}
|
2015-08-22 06:14:21 -04:00
|
|
|
{{ postfix.aliases_file }}:
|
2014-04-23 15:02:09 -04:00
|
|
|
file.managed:
|
|
|
|
- source: salt://postfix/aliases
|
|
|
|
- user: root
|
|
|
|
- group: root
|
|
|
|
- mode: 644
|
|
|
|
- template: jinja
|
|
|
|
- require:
|
|
|
|
- pkg: postfix
|
|
|
|
|
|
|
|
run-newaliases:
|
|
|
|
cmd.wait:
|
|
|
|
- name: newaliases
|
|
|
|
- cwd: /
|
|
|
|
- watch:
|
2015-08-22 06:14:21 -04:00
|
|
|
- file: {{ postfix.aliases_file }}
|
2014-04-23 15:02:09 -04:00
|
|
|
{% endif %}
|
|
|
|
|
2016-04-08 11:50:52 -04:00
|
|
|
# manage various mappings
|
|
|
|
{% for mapping, data in salt['pillar.get']('postfix:mapping', {}).items() %}
|
|
|
|
{%- set need_postmap = False %}
|
|
|
|
{%- set file_path = salt['pillar.get']('postfix:config:' ~ mapping) %}
|
|
|
|
{%- if ':' in file_path %}
|
|
|
|
{%- set file_path = file_path.split(':')[1] %}
|
|
|
|
{%- set need_postmap = True %}
|
|
|
|
{%- endif %}
|
|
|
|
postfix_{{ mapping }}:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ file_path }}
|
|
|
|
- source: salt://postfix/files/mapping.j2
|
|
|
|
- user: root
|
|
|
|
- group: root
|
2016-04-08 11:54:09 -04:00
|
|
|
{%- if mapping.endswith('_sasl_password_maps') %}
|
2016-04-08 11:50:52 -04:00
|
|
|
- mode: 600
|
|
|
|
{%- else %}
|
|
|
|
- mode: 644
|
|
|
|
{%- endif %}
|
|
|
|
- template: jinja
|
|
|
|
- context:
|
|
|
|
data: {{ data|json() }}
|
|
|
|
- require:
|
|
|
|
- pkg: postfix
|
|
|
|
{%- if need_postmap %}
|
|
|
|
cmd.wait:
|
|
|
|
- name: /usr/sbin/postmap {{ file_path }}
|
|
|
|
- cwd: /
|
|
|
|
- watch:
|
|
|
|
- file: {{ file_path }}
|
|
|
|
- watch_in:
|
|
|
|
- service: postfix
|
|
|
|
{%- endif %}
|
|
|
|
{% endfor %}
|