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

- name: install postfix
  pacman: name=postfix state=present

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
    - relay_transport_map
15
    - users.pcre
16
  notify:
17
    - restart postfix
18
    - postmap additional files
19
    - update aliases db
Florian Pritz's avatar
Florian Pritz committed
20

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

Florian Pritz's avatar
Florian Pritz committed
38
39
- 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
40
  notify:
Florian Pritz's avatar
Florian Pritz committed
41
42
43
44
    - reload postfix

- name: create dhparam 512
  command: openssl dhparam -out /etc/postfix/dh_512.pem 512 creates=/etc/postfix/dh_512.pem
Florian Pritz's avatar
Florian Pritz committed
45
  notify:
Florian Pritz's avatar
Florian Pritz committed
46
47
    - reload postfix

48
49
50
51
- 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

52
- name: install bouncehandler config
53
  template: src=wiki-bouncehandler.conf.j2 dest={{ postfix_wiki_bounce_config }} owner={{ postfix_wiki_bounce_user }} group=root mode=0600
54
55
56
57
58
59
60
  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
61
  copy: src=bouncehandler.pl dest={{ postfix_wiki_bounce_mail_handler }} owner=root group=root mode=0755
62
63
64
  when: postfix_server

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

Florian Pritz's avatar
Florian Pritz committed
67
- name: start and enable postfix
Florian Pritz's avatar
Florian Pritz committed
68
  service: name=postfix enabled=yes state=started
Florian Pritz's avatar
Florian Pritz committed
69
70

- name: remove old files
71
  file: path={{ item }} state=absent
Florian Pritz's avatar
Florian Pritz committed
72
73
74
  with_items:
    - compat_maps
    - compat_maps.db
75

76
- name: install extra packages for relaying via smarthost
77
  when: postfix_relayhost | length > 0
78
79
80
81
82
  package:
    name: cyrus-sasl
    state: present

- name: install relay_passwords file
83
  when: postfix_relayhost | length > 0
84
85
86
87
88
89
90
91
92
93
94
  template:
    src: relay_passwords.j2
    dest: /etc/postfix/relay_passwords
    mode: 0640
    owner: root
    group: postfix
  notify:
    - postmap relay_passwords

- name: create user account on orion to relay with
  delegate_to: orion.archlinux.org
95
  when: postfix_relayhost | length > 0
96
  user:
97
98
    name: "{{ inventory_hostname_short }}"
    comment: "SMTP Relay Account for {{ inventory_hostname }}"
99
    group: nobody
100
    password: "{{ postfix_relay_password | password_hash('sha512') }}"
101
    shell: /sbin/nologin
102
    update_password: always
Jelle van der Waa's avatar
Jelle van der Waa committed
103
    home: / # Set home directory so shadow.service does not fail
104
105
    create_home: no

106
- name: open firewall holes
107
  firewalld: service={{ item }} permanent=true state=enabled immediate=yes
108
109
110
  with_items:
    - smtp
    - smtp-submission
Florian Pritz's avatar
Florian Pritz committed
111
  when: postfix_smtpd_public and configure_firewall
112
113
  tags:
    - firewall