Add configuration for virtual and relay domains and aliases
This commit is contained in:
parent
8d7838ad26
commit
bce2d91ea3
8 changed files with 81 additions and 24 deletions
14
tasks/aliases.yml
Normal file
14
tasks/aliases.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
- name: "Aliases | Copy lookup tables from templates"
|
||||
ansible.builtin.template:
|
||||
src: postfix/conf.d/virtual_aliases
|
||||
dest: "{{ postfix_conf_dir }}/"
|
||||
mode: "0644"
|
||||
notify: reload postfix
|
||||
|
||||
- name: "Domains | Run postmap"
|
||||
ansible.builtin.command: "postmap cdb:virtual_aliases"
|
||||
args:
|
||||
chdir: "{{ postfix_conf_dir }}"
|
||||
changed_when: false
|
||||
notify: reload postfix
|
20
tasks/domains.yml
Normal file
20
tasks/domains.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
- name: "Domains | Copy lookup tables from templates"
|
||||
ansible.builtin.template:
|
||||
src: "postfix/conf.d/{{ item }}.j2"
|
||||
dest: "{{ postfix_conf_dir }}/{{ item }}"
|
||||
mode: "0644"
|
||||
notify: reload postfix
|
||||
loop:
|
||||
- relay_domains
|
||||
- virtual_domains
|
||||
|
||||
- name: "Domains | Run postmap"
|
||||
ansible.builtin.command: "postmap cdb:{{ item }}"
|
||||
args:
|
||||
chdir: "{{ postfix_conf_dir }}"
|
||||
changed_when: false
|
||||
notify: reload postfix
|
||||
loop:
|
||||
- relay_domains
|
||||
- virtual_domains
|
|
@ -7,9 +7,13 @@
|
|||
ansible.builtin.import_tasks: postfix.yml
|
||||
tags: postfix
|
||||
|
||||
- name: Virtual domains
|
||||
ansible.builtin.import_tasks: virtual_domains.yml
|
||||
tags: virtual_domains
|
||||
- name: Domains
|
||||
ansible.builtin.import_tasks: domains.yml
|
||||
tags: domains
|
||||
|
||||
- name: Aliases
|
||||
ansible.builtin.import_tasks: aliases.yml
|
||||
tags: aliases
|
||||
|
||||
- name: OnionMX
|
||||
ansible.builtin.import_tasks: onionmx.yml
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
---
|
||||
- name: "Virtual domain | Copy lookup tables from templates"
|
||||
ansible.builtin.template:
|
||||
src: "postfix/conf.d/virtual_domains.j2"
|
||||
dest: "{{ postfix_conf_dir }}/virtual_domains"
|
||||
mode: "0644"
|
||||
notify: reload postfix
|
||||
|
||||
- name: "Postfix | Run postmap"
|
||||
ansible.builtin.command: "postmap cdb:virtual_domains"
|
||||
args:
|
||||
chdir: "{{ postfix_conf_dir }}"
|
||||
changed_when: false
|
||||
notify: reload postfix
|
9
templates/postfix/conf.d/relay_domains.j2
Normal file
9
templates/postfix/conf.d/relay_domains.j2
Normal file
|
@ -0,0 +1,9 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
{% if postfix_domains is defined %}
|
||||
{% for domain in postfix_domains %}
|
||||
{% if domain.type == "relay" %}
|
||||
{{ "%-50s %s" | format(domain.name, "#domain") }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
25
templates/postfix/conf.d/virtual_aliases.j2
Normal file
25
templates/postfix/conf.d/virtual_aliases.j2
Normal file
|
@ -0,0 +1,25 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
# Example variables list
|
||||
#
|
||||
# postfix_aliases:
|
||||
# - domain: mydomain.org
|
||||
# comment: |
|
||||
# Mydomain.org
|
||||
# List of Aliases
|
||||
# aliases:
|
||||
# - name: foo
|
||||
# dest:
|
||||
# - "alice@yourdomain.org
|
||||
# - "bob@yourdomain.org
|
||||
|
||||
{% if postfix_aliases is defined %}
|
||||
{% for domain in postfix_aliases %}
|
||||
{% if domain.comment is defined %}
|
||||
# {{ domain.comment }}
|
||||
{% endif %}
|
||||
{% for alias in domain.aliases %}
|
||||
{{ "%-50s %s" | format(alias.name, alias.dest | join(',')) }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
|
@ -1,7 +1,9 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
{% if postfix_virtual_domains is defined %}
|
||||
{% for domain in postfix_virtual_domains %}
|
||||
{% if postfix_domains is defined %}
|
||||
{% for domain in postfix_domains %}
|
||||
{% if domain.type == "virtual" %}
|
||||
{{ "%-50s %s" | format(domain.name, "#domain") }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
|
|
@ -84,12 +84,9 @@ virtual_transport =
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if postfix_relay_domains is defined %}
|
||||
{% if postfix_relay_domains is defined and postfix_relay_domains %}
|
||||
# Relay mails without recipient check
|
||||
relay_domains =
|
||||
{% for map in postfix_relay_domains %}
|
||||
{{ map.type}}:{{ map.path }}
|
||||
{% endfor %}
|
||||
relay_domains = cdb:{{ postfix_conf_dir }}/relay_domains
|
||||
{% endif %}
|
||||
{% if postfix_sender_dependent_relayhost_maps is defined %}
|
||||
sender_dependent_relayhost_maps =
|
||||
|
|
Loading…
Reference in a new issue