also manage sender_transport_map
[ansible.git] / roles / email / tasks / postfix.yml
1 - name: install postfix
2   apt: name=postfix,bsd-mailx state=latest
3 - name: install postfix-mysql
4   when: postfix.dovecot is defined
5   apt: name=postfix-mysql state=latest
6 - name: enable postfix
7   service: name=postfix enabled=yes
8 # config
9 - name: install postfix config
10   template:
11     dest: /etc/postfix/{{ item }}
12     src: templates/{{ item }}
13   loop:
14   - main.cf
15   - master.cf
16   notify: postfix
17 - name: install postfix mysql config
18   when: postfix.dovecot is defined
19   template:
20     dest: /etc/postfix/{{ item }}
21     src: templates/{{ item }}
22     mode: u=rw,g=r,o=
23     group: postfix
24   loop:
25   - mysql_vmail_aliases.cf
26   - mysql_vmail_senders.cf
27   - mysql_vmail_users.cf
28   notify: postfix
29 - name: give postfix user access to opendkim
30   # we assume the user alredy exists (it is created above by installing postfix)
31   when: postfix.opendkim is defined
32   user:
33     name: postfix
34     groups: opendkim
35     append: yes
36   notify: postfix
37 # maps
38 - name: create empty virtual_alias_map
39   register: virtual_alias_map
40   copy:
41     dest: /etc/postfix/virtual_alias_map
42     content: ""
43     force: no
44 - name: postmap virtual_alias_map
45   when: virtual_alias_map.changed
46   command: postmap /etc/postfix/virtual_alias_map
47   notify: postfix
48 - name: create sender_transport_map
49   when: postfix.smtp_outgoing is defined
50   register: sender_transport_map
51   template:
52     dest: /etc/postfix/sender_transport_map
53     src: templates/sender_transport_map
54 - name: postmap sender_transport_map
55   when: sender_transport_map.changed
56   command: postmap /etc/postfix/sender_transport_map
57   notify: postfix
58 - name: create relay_clientcerts
59   when: postfix.relay_client_cert_whitelist is defined
60   register: relay_clientcerts
61   template:
62     dest: /etc/postfix/relay_clientcerts
63     src: templates/relay_clientcerts
64 - name: postmap relay_clientcerts
65   when: relay_clientcerts.changed
66   command: postmap /etc/postfix/relay_clientcerts
67   notify: postfix
68 - name: create transport_map
69   register: transport_map
70   template:
71     dest: /etc/postfix/transport_map
72     src: templates/transport_map
73 - name: postmap transport_map
74   when: transport_map.changed
75   command: postmap /etc/postfix/transport_map
76   notify: postfix
77 # cronjobs
78 - name: delete old local-mail cronjob
79   file: path=/etc/cron.daily/local-mail state=absent
80 - name: install check-for-local-mail cronjob
81   copy:
82     dest: /etc/cron.daily/check-for-local-mail
83     src: files/check-for-local-mail
84     mode: u=rwx,g=rx,o=rx