2017-08-24 13:02:46 +02:00
|
|
|
{% from "postfix/map.jinja" import postfix with context %}
|
2014-08-20 02:32:47 +02:00
|
|
|
include:
|
|
|
|
- postfix
|
|
|
|
|
2021-03-14 22:33:21 +01:00
|
|
|
postfix-config-file-directory-config-path:
|
2014-08-20 02:32:47 +02:00
|
|
|
file.directory:
|
2021-03-14 22:33:21 +01:00
|
|
|
- name: {{ postfix.config_path }}
|
2014-08-20 02:32:47 +02:00
|
|
|
- user: root
|
2017-08-24 13:02:46 +02:00
|
|
|
- group: {{ postfix.root_grp }}
|
2020-10-02 19:49:13 +02:00
|
|
|
- dir_mode: '0755'
|
|
|
|
- file_mode: '0644'
|
2014-08-20 02:32:47 +02:00
|
|
|
- makedirs: True
|
|
|
|
|
2021-03-14 22:33:21 +01:00
|
|
|
postfix-config-file-managed-main.cf:
|
2014-08-20 02:32:47 +02:00
|
|
|
file.managed:
|
2021-03-14 22:33:21 +01:00
|
|
|
- name: {{ postfix.config_path }}/main.cf
|
2014-08-20 02:32:47 +02:00
|
|
|
- source: salt://postfix/files/main.cf
|
|
|
|
- user: root
|
2017-08-24 13:02:46 +02:00
|
|
|
- group: {{ postfix.root_grp }}
|
2020-10-02 19:49:13 +02:00
|
|
|
- mode: '0644'
|
2014-08-20 03:42:08 +02:00
|
|
|
- require:
|
2021-03-14 22:33:21 +01:00
|
|
|
- pkg: postfix-init-pkg-installed-postfix
|
2014-08-20 02:32:47 +02:00
|
|
|
- watch_in:
|
2021-03-14 22:33:21 +01:00
|
|
|
- service: postfix-init-service-running-postfix
|
2014-08-20 02:32:47 +02:00
|
|
|
- template: jinja
|
2020-05-08 08:33:10 +02:00
|
|
|
- context:
|
|
|
|
postfix: {{ postfix|tojson }}
|
2015-06-21 01:18:55 +02:00
|
|
|
|
|
|
|
{% if 'vmail' in pillar.get('postfix', '') %}
|
2021-03-14 22:33:21 +01:00
|
|
|
postfix-config-file-managed-virtual-alias-maps.cf:
|
2015-06-21 01:18:55 +02:00
|
|
|
file.managed:
|
2021-03-14 22:33:21 +01:00
|
|
|
- name: {{ postfix.config_path }}/virtual_alias_maps.cf
|
2015-06-21 01:18:55 +02:00
|
|
|
- source: salt://postfix/files/virtual_alias_maps.cf
|
|
|
|
- user: root
|
|
|
|
- group: postfix
|
2020-10-02 19:49:13 +02:00
|
|
|
- mode: '0640'
|
2015-06-21 01:18:55 +02:00
|
|
|
- require:
|
2021-03-14 22:33:21 +01:00
|
|
|
- pkg: postfix-init-pkg-installed-postfix
|
2015-06-21 01:18:55 +02:00
|
|
|
- watch_in:
|
2021-03-14 22:33:21 +01:00
|
|
|
- service: postfix-init-service-running-postfix
|
2015-06-21 01:18:55 +02:00
|
|
|
- template: jinja
|
|
|
|
|
2021-03-14 22:33:21 +01:00
|
|
|
postfix-config-file-managed-virtual-mailbox-domains.cf:
|
2015-06-21 01:18:55 +02:00
|
|
|
file.managed:
|
2021-03-14 22:33:21 +01:00
|
|
|
- name: {{ postfix.config_path }}/virtual_mailbox_domains.cf
|
2015-06-21 01:18:55 +02:00
|
|
|
- source: salt://postfix/files/virtual_mailbox_domains.cf
|
|
|
|
- user: root
|
|
|
|
- group: postfix
|
2020-10-02 19:49:13 +02:00
|
|
|
- mode: '0640'
|
2015-06-21 01:18:55 +02:00
|
|
|
- require:
|
2021-03-14 22:33:21 +01:00
|
|
|
- pkg: postfix-init-pkg-installed-postfix
|
2015-06-21 01:18:55 +02:00
|
|
|
- watch_in:
|
2021-03-14 22:33:21 +01:00
|
|
|
- service: postfix-init-service-running-postfix
|
2015-06-21 01:18:55 +02:00
|
|
|
- template: jinja
|
|
|
|
|
2021-03-14 22:33:21 +01:00
|
|
|
postfix-config-file-managed-virtual-mailbox-maps.cf:
|
2015-06-21 01:18:55 +02:00
|
|
|
file.managed:
|
2021-03-14 22:33:21 +01:00
|
|
|
- name: {{ postfix.config_path }}/virtual_mailbox_maps.cf
|
2015-06-21 01:18:55 +02:00
|
|
|
- source: salt://postfix/files/virtual_mailbox_maps.cf
|
|
|
|
- user: root
|
|
|
|
- group: postfix
|
2020-10-02 19:49:13 +02:00
|
|
|
- mode: '0640'
|
2015-06-21 01:18:55 +02:00
|
|
|
- require:
|
2021-03-14 22:33:21 +01:00
|
|
|
- pkg: postfix-init-pkg-installed-postfix
|
2015-06-21 01:18:55 +02:00
|
|
|
- watch_in:
|
2021-03-14 22:33:21 +01:00
|
|
|
- service: postfix-init-service-running-postfix
|
2015-06-21 01:18:55 +02:00
|
|
|
- template: jinja
|
|
|
|
{% endif %}
|
|
|
|
|
2015-03-26 09:43:44 +01:00
|
|
|
{% if salt['pillar.get']('postfix:manage_master_config', True) %}
|
2020-05-08 08:33:10 +02:00
|
|
|
{% import_yaml "postfix/services.yaml" as postfix_master_services %}
|
2021-03-14 22:33:21 +01:00
|
|
|
postfix-config-file-managed-master.cf:
|
2015-02-05 09:57:18 +01:00
|
|
|
file.managed:
|
2021-03-14 22:33:21 +01:00
|
|
|
- name: {{ postfix.config_path }}/master.cf
|
2015-02-05 09:57:18 +01:00
|
|
|
- source: salt://postfix/files/master.cf
|
|
|
|
- user: root
|
2017-08-24 13:02:46 +02:00
|
|
|
- group: {{ postfix.root_grp }}
|
2020-10-02 19:49:13 +02:00
|
|
|
- mode: '0644'
|
2015-02-05 09:57:18 +01:00
|
|
|
- require:
|
2021-03-14 22:33:21 +01:00
|
|
|
- pkg: postfix-init-pkg-installed-postfix
|
2015-02-05 09:57:18 +01:00
|
|
|
- watch_in:
|
2021-03-14 22:33:21 +01:00
|
|
|
- service: postfix-init-service-running-postfix
|
2015-02-05 09:57:18 +01:00
|
|
|
- template: jinja
|
2020-05-08 08:33:10 +02:00
|
|
|
- context:
|
|
|
|
postfix: {{ postfix|tojson }}
|
|
|
|
postfix_master_services: {{ postfix_master_services|tojson }}
|
2015-03-25 12:49:57 +01:00
|
|
|
{% endif %}
|
2015-06-20 22:49:09 +02:00
|
|
|
|
2015-08-30 19:30:08 +02:00
|
|
|
{%- for domain in salt['pillar.get']('postfix:certificates', {}).keys() %}
|
|
|
|
|
2021-03-14 22:33:21 +01:00
|
|
|
postfix-config-file-managed-{{ domain }}-ssl-certificate:
|
2015-06-20 22:49:09 +02:00
|
|
|
file.managed:
|
2017-08-24 13:02:46 +02:00
|
|
|
- name: {{ postfix.config_path }}/ssl/{{ domain }}.crt
|
2015-08-30 19:30:08 +02:00
|
|
|
- makedirs: True
|
|
|
|
- contents_pillar: postfix:certificates:{{ domain }}:public_cert
|
2015-06-20 22:49:09 +02:00
|
|
|
- watch_in:
|
2021-03-14 22:33:21 +01:00
|
|
|
- service: postfix-init-service-running-postfix
|
2015-06-20 22:49:09 +02:00
|
|
|
|
2021-03-14 22:33:21 +01:00
|
|
|
postfix-config-file-managed-{{ domain }}-ssl-key:
|
2015-06-20 22:49:09 +02:00
|
|
|
file.managed:
|
2017-08-24 13:02:46 +02:00
|
|
|
- name: {{ postfix.config_path }}/ssl/{{ domain }}.key
|
2020-10-02 19:49:13 +02:00
|
|
|
- mode: '0600'
|
2015-08-30 19:30:08 +02:00
|
|
|
- makedirs: True
|
|
|
|
- contents_pillar: postfix:certificates:{{ domain }}:private_key
|
2015-06-20 22:49:09 +02:00
|
|
|
- watch_in:
|
2021-03-14 22:33:21 +01:00
|
|
|
- service: postfix-init-service-running-postfix
|
2015-06-20 22:49:09 +02:00
|
|
|
|
2015-08-30 19:30:08 +02:00
|
|
|
{% endfor %}
|
2020-06-07 14:26:56 +02: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 file_path.startswith('proxy:') %}
|
|
|
|
{#- Discard the proxy:-prefix #}
|
|
|
|
{%- set _, file_type, file_path = file_path.split(':') %}
|
|
|
|
{%- elif ':' in file_path %}
|
|
|
|
{%- set file_type, file_path = file_path.split(':') %}
|
|
|
|
{%- else %}
|
|
|
|
{%- set file_type = default_database_type %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if not file_path.startswith('/') %}
|
|
|
|
{%- set file_path = postfix.config_path ~ '/' ~ file_path %}
|
|
|
|
{%- endif %}
|
2020-07-18 21:40:19 +02:00
|
|
|
{%- if file_type in ("btree", "cdb", "cidr", "dbm", "hash", "pcre", "regexp", "sdbm") %}
|
2020-06-07 14:26:56 +02:00
|
|
|
{%- set need_postmap = True %}
|
|
|
|
{%- endif %}
|
2021-03-14 22:33:21 +01:00
|
|
|
postfix-config-file-managed-{{ mapping }}:
|
2020-06-07 14:26:56 +02:00
|
|
|
file.managed:
|
|
|
|
- name: {{ file_path }}
|
|
|
|
- source: salt://postfix/files/mapping.j2
|
|
|
|
- user: root
|
|
|
|
- group: {{ postfix.root_grp }}
|
|
|
|
{%- if mapping.endswith('_sasl_password_maps') %}
|
2020-10-02 19:49:13 +02:00
|
|
|
- mode: '0600'
|
2020-06-07 14:26:56 +02:00
|
|
|
{%- else %}
|
2020-10-02 19:49:13 +02:00
|
|
|
- mode: '0644'
|
2020-06-07 14:26:56 +02:00
|
|
|
{%- endif %}
|
|
|
|
- template: jinja
|
|
|
|
- context:
|
|
|
|
data: {{ data|json() }}
|
|
|
|
- require:
|
2021-03-14 22:33:21 +01:00
|
|
|
- pkg: postfix-init-pkg-installed-postfix
|
|
|
|
- file: postfix-config-file-managed-main.cf
|
2020-06-07 14:26:56 +02:00
|
|
|
{%- if need_postmap %}
|
2021-03-14 22:33:21 +01:00
|
|
|
postfix-config-cmd-wait-{{ mapping }}:
|
2020-06-07 14:26:56 +02:00
|
|
|
cmd.wait:
|
|
|
|
- name: {{ postfix.xbin_prefix }}/sbin/postmap {{ file_path }}
|
|
|
|
- cwd: /
|
|
|
|
- watch:
|
2021-03-14 22:33:21 +01:00
|
|
|
- file: postfix-config-file-managed-{{ mapping }}
|
2020-06-07 14:26:56 +02:00
|
|
|
- watch_in:
|
2021-03-14 22:33:21 +01:00
|
|
|
- service: postfix-init-service-running-postfix
|
2020-06-07 14:26:56 +02:00
|
|
|
{%- endif %}
|
|
|
|
{% endfor %}
|