ansible-mailserver-debian/mail_system/tasks/postfix.yml

89 lines
2 KiB
YAML
Raw Permalink Normal View History

2026-03-22 13:09:26 +01:00
- name: Install postfix packages
ansible.builtin.apt:
2019-09-19 10:43:17 +02:00
name: postfix,postfix-pgsql,postfix-doc
state: present
2026-03-22 13:09:26 +01:00
update_cache: true
install_recommends: false
2019-09-19 10:43:17 +02:00
2026-03-22 13:09:26 +01:00
- name: Divert /etc/postfix/main.cf
community.general.dpkg_divert:
path: /etc/postfix/main.cf
divert: /etc/postfix/main.cf.orig
rename: true
2019-09-19 10:43:17 +02:00
2026-03-22 13:09:26 +01:00
- name: Divert /etc/postfix/master.cf
community.general.dpkg_divert:
path: /etc/postfix/master.cf
divert: /etc/postfix/master.cf.orig
rename: true
2019-09-19 10:43:17 +02:00
2026-03-22 13:09:26 +01:00
- name: Group 'mailstore'
ansible.builtin.group:
2019-09-19 10:43:17 +02:00
name: mailstore
state: present
2026-03-22 13:09:26 +01:00
system: true
2019-09-19 10:43:17 +02:00
gid: 5000
2026-03-22 13:09:26 +01:00
- name: User 'mailstore'
ansible.builtin.user:
2019-09-19 10:43:17 +02:00
name: mailstore
group: mailstore
state: present
shell: /usr/sbin/nologin
2026-03-22 13:09:26 +01:00
system: true
2019-09-19 10:43:17 +02:00
uid: 5000
2026-03-22 13:09:26 +01:00
create_home: false
2019-09-19 10:43:17 +02:00
home: /srv/mailstore
password: '!'
2026-03-22 13:09:26 +01:00
password_lock: true
2019-09-19 10:43:17 +02:00
comment: created by ansible
2026-03-22 13:09:26 +01:00
- name: Directories /srv/mailstore /srv/mailstore/role_specific
ansible.builtin.file:
2019-09-19 10:43:17 +02:00
path: "{{ item }}"
state: directory
owner: mailstore
group: mailstore
2026-03-22 13:09:26 +01:00
mode: "0755"
2019-09-19 10:43:17 +02:00
loop:
- /srv/mailstore
- /srv/mailstore/role_specific
- /srv/mailstore/role_specific/roles
2026-03-22 13:09:26 +01:00
- name: Postfix configuration files
ansible.builtin.template:
2019-09-19 10:43:17 +02:00
src: "postfix/{{ item }}"
dest: "/etc/postfix/{{ item }}"
owner: root
group: root
2026-03-22 13:09:26 +01:00
mode: "0644"
2019-09-19 10:43:17 +02:00
force: "{{ mailserver.postfix.overwrite_config }}"
loop:
- main.cf
- master.cf
- header_checks
2026-03-22 13:09:26 +01:00
- name: Postfix database queries
ansible.builtin.template:
2019-09-19 10:43:17 +02:00
src: "postfix/{{ item }}"
dest: "/etc/postfix/{{ item }}"
owner: root
group: root
2026-03-22 13:09:26 +01:00
mode: "0600"
force: true
2019-09-19 10:43:17 +02:00
loop:
- domains.cf
- mailboxes.cf
- aliases.cf
- email_existence_check.cf
- relay_domains.cf
- relay_recipient_maps.cf
- transport_maps.cf
- sender_canonical_maps.cf
- recipient_canonical_maps.cf
2019-09-19 10:43:17 +02:00
2026-03-22 13:09:26 +01:00
- name: Restart postfix
ansible.builtin.systemd:
2019-09-19 10:43:17 +02:00
name: postfix
state: restarted