main.yml 3.08 KB
Newer Older
Florian Pritz's avatar
Florian Pritz committed
1
2
3
---

- name: install postfix
4
  pacman: name=postfix,postfix-pcre state=present
Florian Pritz's avatar
Florian Pritz committed
5

6
- name: install template configs
7
  template: src={{ item }}.j2 dest=/etc/postfix/{{ item }} owner=root group=root mode=0644
8
9
10
11
  with_items:
    - main.cf
    - master.cf
    - transport
12
    - transport.pcre
13
    - aliases
14
    - users.pcre
15
  notify:
16
    - restart postfix
17
    - postmap additional files
18
    - update aliases db
Florian Pritz's avatar
Florian Pritz committed
19

20
- name: install additional files
21
  copy: src={{ item }} dest=/etc/postfix/{{ item }} owner=root group=root mode=0644
22
23
24
  with_items:
    - access_client
    - access_sender
25
    - access_sender-post-filter
26
    - access_helo
27
    - access_recipient
28
29
30
    - body_checks
    - header_checks
    - relocated
31
32
    - domains
    - mailman_compat
33
    - msa_header_checks
34
35
  notify:
    - postmap additional files
36

Florian Pritz's avatar
Florian Pritz committed
37
38
- name: create dhparam 2048
  command: openssl dhparam -out /etc/postfix/dh2048.pem 2048 creates=/etc/postfix/dh2048.pem
Florian Pritz's avatar
Florian Pritz committed
39
  notify:
Florian Pritz's avatar
Florian Pritz committed
40
41
    - reload postfix

42
43
44
45
- name: install postfix cert renewal hook
  template: src=letsencrypt.hook.d.j2 dest=/etc/letsencrypt/hook.d/postfix owner=root group=root mode=0755
  when: postfix_smtpd_public

46
- name: install bouncehandler config
47
  template: src=wiki-bouncehandler.conf.j2 dest={{ postfix_wiki_bounce_config }} owner={{ postfix_wiki_bounce_user }} group=root mode=0600
48
49
50
51
52
53
54
  when: postfix_server

- name: install packages for bounce handler
  pacman: name=perl-mediawiki-api,perl-config-simple state=present
  when: postfix_server

- name: install bouncehandler script
55
  copy: src=bouncehandler.pl dest={{ postfix_wiki_bounce_mail_handler }} owner=root group=root mode=0755
56
57
58
  when: postfix_server

- name: make bouncehandler user
59
  user: name={{ postfix_wiki_bounce_user }} shell=/bin/false skeleton=/var/empty state={{ "present" if postfix_server else "absent" }}
60

Florian Pritz's avatar
Florian Pritz committed
61
- name: start and enable postfix
Florian Pritz's avatar
Florian Pritz committed
62
  service: name=postfix enabled=yes state=started
Florian Pritz's avatar
Florian Pritz committed
63
64

- name: remove old files
65
  file: path={{ item }} state=absent
Florian Pritz's avatar
Florian Pritz committed
66
67
68
  with_items:
    - compat_maps
    - compat_maps.db
69

70
- name: install extra packages for relaying via smarthost
71
  when: postfix_relayhost | length > 0
72
73
74
75
76
  package:
    name: cyrus-sasl
    state: present

- name: install relay_passwords file
77
  when: postfix_relayhost | length > 0
78
79
80
81
82
83
84
85
86
  template:
    src: relay_passwords.j2
    dest: /etc/postfix/relay_passwords
    mode: 0640
    owner: root
    group: postfix
  notify:
    - postmap relay_passwords

87
88
- name: create user account on mail to relay with
  delegate_to: mail.archlinux.org
89
  when: postfix_relayhost | length > 0
90
  user:
91
92
    name: "{{ inventory_hostname_short }}"
    comment: "SMTP Relay Account for {{ inventory_hostname }}"
93
    group: nobody
94
    password: "{{ postfix_relay_password | password_hash('sha512') }}"
95
    shell: /sbin/nologin
96
    update_password: always
Kristian Klausen's avatar
Kristian Klausen committed
97
98
    home: /home/"{{ inventory_hostname }}"  # Set home directory so shadow.service does not fail
    create_home: true
99

100
- name: open firewall holes
101
  ansible.posix.firewalld: service={{ item }} permanent=true state=enabled immediate=yes
102
103
104
  with_items:
    - smtp
    - smtp-submission
105
    - smtps
106
  when: postfix_smtpd_public and configure_firewall
107
108
  tags:
    - firewall