ignore more SSH errors
[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   - postscreen_access.cidr
17   notify: postfix
18 - name: install postfix mysql config
19   when: postfix.dovecot is defined
20   template:
21     dest: /etc/postfix/{{ item }}
22     src: templates/{{ item }}
23     mode: u=rw,g=r,o=
24     group: postfix
25   loop:
26   - mysql_vmail_aliases.cf
27   - mysql_vmail_senders.cf
28   - mysql_vmail_users.cf
29   notify: postfix
30 - name: give postfix user access to opendkim
31   # we assume the user alredy exists (it is created above by installing postfix)
32   when: postfix.opendkim is defined
33   user:
34     name: postfix
35     groups: opendkim
36     append: yes
37   notify: postfix
38 # maps
39 - name: create empty virtual_alias_map
40   register: virtual_alias_map
41   copy:
42     dest: /etc/postfix/virtual_alias_map
43     content: ""
44     force: no
45 - name: postmap virtual_alias_map
46   when: virtual_alias_map.changed
47   command: postmap /etc/postfix/virtual_alias_map
48   notify: postfix
49 - name: create sender_transport_map
50   when: postfix.smtp_outgoing is defined
51   register: sender_transport_map
52   template:
53     dest: /etc/postfix/sender_transport_map
54     src: templates/sender_transport_map
55 - name: postmap sender_transport_map
56   when: sender_transport_map.changed
57   command: postmap /etc/postfix/sender_transport_map
58   notify: postfix
59 - name: create relay_clientcerts
60   when: postfix.relay_client_cert_whitelist is defined
61   register: relay_clientcerts
62   template:
63     dest: /etc/postfix/relay_clientcerts
64     src: templates/relay_clientcerts
65 - name: postmap relay_clientcerts
66   when: relay_clientcerts.changed
67   command: postmap /etc/postfix/relay_clientcerts
68   notify: postfix
69 - name: create transport_map
70   register: transport_map
71   template:
72     dest: /etc/postfix/transport_map
73     src: templates/transport_map
74 - name: postmap transport_map
75   when: transport_map.changed
76   command: postmap /etc/postfix/transport_map
77   notify: postfix
78 # cronjobs
79 - name: install check-for-local-mail cronjob
80   copy:
81     dest: /etc/cron.daily/check-for-local-mail
82     src: files/check-for-local-mail
83     mode: u=rwx,g=rx,o=rx