2015-02-26 16:19:08 +01:00
|
|
|
{% from "postfix/map.jinja" import postfix with context %}
|
|
|
|
|
2013-06-13 07:55:32 +02:00
|
|
|
postfix:
|
2015-02-26 16:19:08 +01:00
|
|
|
pkg.installed:
|
2015-08-22 12:46:35 +02:00
|
|
|
- name: {{ postfix.package }}
|
2015-02-26 16:19:08 +01:00
|
|
|
- watch_in:
|
|
|
|
- service: postfix
|
2013-06-13 07:55:32 +02:00
|
|
|
service.running:
|
2016-05-18 19:29:37 +02:00
|
|
|
- enable: {{ salt['pillar.get']('postfix:enable_service', True) }}
|
2013-06-13 07:55:32 +02:00
|
|
|
- require:
|
|
|
|
- pkg: postfix
|
2014-04-23 21:02:09 +02:00
|
|
|
- watch:
|
|
|
|
- pkg: postfix
|
|
|
|
|
2015-12-29 11:28:35 +01:00
|
|
|
{%- macro postmap_file(filename, mode=644) %}
|
2015-10-02 23:12:37 +02:00
|
|
|
{%- set file_path = '/etc/postfix/' ~ filename %}
|
|
|
|
postmap_{{ filename }}:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ file_path }}
|
|
|
|
- source: salt://postfix/{{ filename }}
|
|
|
|
- user: root
|
|
|
|
- group: root
|
2015-12-29 11:28:35 +01:00
|
|
|
- mode: {{ mode }}
|
2015-10-02 23:12:37 +02:00
|
|
|
- template: jinja
|
|
|
|
- require:
|
|
|
|
- pkg: postfix
|
|
|
|
cmd.wait:
|
|
|
|
- name: /usr/sbin/postmap {{ file_path }}
|
|
|
|
- cwd: /
|
|
|
|
- watch:
|
|
|
|
- file: {{ file_path }}
|
|
|
|
{%- endmacro %}
|
|
|
|
|
2014-04-23 21:02:09 +02:00
|
|
|
# manage /etc/aliases if data found in pillar
|
|
|
|
{% if 'aliases' in pillar.get('postfix', '') %}
|
2015-08-22 12:14:21 +02:00
|
|
|
{{ postfix.aliases_file }}:
|
2014-04-23 21:02:09 +02: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 12:14:21 +02:00
|
|
|
- file: {{ postfix.aliases_file }}
|
2014-04-23 21:02:09 +02:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
# manage /etc/postfix/virtual if data found in pillar
|
|
|
|
{% if 'virtual' in pillar.get('postfix', '') %}
|
2015-10-02 23:12:37 +02:00
|
|
|
{{ postmap_file('virtual') }}
|
2014-04-23 21:02:09 +02:00
|
|
|
{% endif %}
|
2015-08-31 22:34:51 +02:00
|
|
|
|
2015-09-02 20:59:57 +02:00
|
|
|
# manage /etc/postfix/sasl_passwd if data found in pillar
|
|
|
|
{% if 'sasl_passwd' in pillar.get('postfix', '') %}
|
2015-12-29 11:28:35 +01:00
|
|
|
{{ postmap_file('sasl_passwd', 600) }}
|
2015-09-02 20:59:57 +02:00
|
|
|
{% endif %}
|
|
|
|
|
2015-08-31 22:34:51 +02:00
|
|
|
# manage /etc/postfix/sender_canonical if data found in pillar
|
|
|
|
{% if 'sender_canonical' in pillar.get('postfix', '') %}
|
2015-10-02 23:12:37 +02:00
|
|
|
{{ postmap_file('sender_canonical') }}
|
2015-08-31 22:34:51 +02:00
|
|
|
{% endif %}
|