fix playall to site.yml, now that that's the only playbook
[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   when: postfix.virtual_mailbox_domains is defined
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 transport_map
50   when: postfix.virtual_mailbox_domains is defined
51   register: transport_map
52   template:
53     dest: /etc/postfix/transport_map
54     src: templates/transport_map
55 - name: postmap transport_map
56   when: transport_map.changed
57   command: postmap /etc/postfix/transport_map
58   notify: postfix
59 # cronjobs
60 - name: delete old local-mail cronjob
61   file: path=/etc/cron.daily/local-mail state=absent
62 - name: install check-for-local-mail cronjob
63   copy:
64     dest: /etc/cron.daily/check-for-local-mail
65     src: files/check-for-local-mail
66     mode: u=rwx,g=rx,o=rx
67 - name: install mailman-check cronjob
68   when: postfix.mailman is defined and postfix.mailman
69   copy:
70     dest: /etc/cron.daily/mailman-check
71     src: files/mailman-check
72     mode: u=rwx,g=rx,o=rx
73 - name: remove mailman-check cronjob
74   when: not (postfix.mailman is defined and postfix.mailman)
75   file:
76     path: /etc/cron.daily/mailman-check
77     state: absent
78 # tools
79 - block:
80   - name: create newmail dir
81     file: path=/root/newmail state=directory
82   - name: install newmail script
83     copy:
84       dest: /root/newmail/newmail
85       src: files/newmail/newmail
86       mode: u=rwx,g=rx,o=rx
87   - name: install newmail templates
88     copy:
89       dest: /root/newmail/templates.py
90       src: files/newmail/templates.py
91   when: postfix.dovecot is defined