summaryrefslogtreecommitdiff
path: root/roles/postfix/tasks/main.yml
blob: 31414f53caca244330269d613fb0c3b103f6fe34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
- name: Install postfix
  ansible.builtin.package:
    name:
      - postfix
      - postfix-pcre
    state: present

- name: Setup correct alias for root mail
  ansible.builtin.lineinfile:
    dest: /etc/postfix/aliases
    state: present
    # YAML requires escape string to be encoded in double quotes.
    regexp: "^(#)?root:\t\t(you|d)"
    line: "root:\t\td"
    owner: root
    group: root
    mode: u+rw,g+r,o+r
  notify:
    - Update aliases
    - Reload postfix

- name: Copy postfix lookup tables
  ansible.builtin.copy:
    src: '{{ item }}'
    dest: /etc/postfix/
    owner: root
    group: root
    mode: u+rw,g+r,o+r
  loop:
    - files/virtual
  notify:
    - Update postfix lookup tables
    - Reload postfix

- name: Copy postfix additional restriction files
  ansible.builtin.copy:
    src: '{{ item }}'
    dest: /etc/postfix/
    owner: root
    group: root
    mode: u+rw,g+r,o+r
  loop:
    - files/sender_access
    - files/body_checks
  notify:
    - Reload postfix

- name: Configure postfix
  ansible.builtin.copy:
    src: '{{ item }}'
    dest: /etc/postfix/
    owner: root
    group: root
    mode: u+rw,g+r,o+r
  loop:
    - files/master.cf
    - files/main.cf
  notify:
    - Check postfix
    - Reload postfix

- name: Copy postfix certificate renewal hook
  ansible.builtin.copy:
    src: files/postfix.sh
    dest: /etc/letsencrypt/renewal-hooks/deploy/postfix.sh
    owner: root
    group: root
    mode: u+rwx,g+r,o+r

- name: Enable postfix systemd service
  ansible.builtin.service:
    name: postfix
    enabled: true
    state: started