]> git.somenet.org - root/pub/somesible.git/blob - roles/server/mail/postfix/tasks/main.yml
roles/server/nginx/vhost-unified
[root/pub/somesible.git] / roles / server / mail / postfix / tasks / main.yml
1 #####################################
2 ### someone's ansible provisioner ###
3 #####################################
4 # Part of: https://git.somenet.org/root/pub/somesible.git
5 # 2017-2024 by someone <someone@somenet.org>
6 #
7 ---
8 - name: install postfix
9   apt:
10     pkg:
11     - postfix
12     state: present
13     policy_rc_d: 101
14   tags: "online"
15   ignore_errors: "{{ignore_online_errors | bool}}"
16
17
18 - name: add postfix user to groups mail,sasl,ssl-cert,letsencrypt,opendkim,opendmarc
19   user:
20     name: "postfix"
21     groups: "mail,sasl,ssl-cert,letsencrypt,opendkim,opendmarc,pyspf-milter"
22     append: yes
23     createhome: no
24     state: present
25
26
27 - name: copy main.cf
28   copy:
29     src: "{{item}}"
30     dest: "/etc/postfix/main.cf"
31     mode: 0644
32     owner: "root"
33     group: "root"
34   with_first_found:
35     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/main.cf"
36     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/main.cf"
37     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/main.cf"
38     - "default/main.cf"
39   notify: restart postfix.service
40
41
42 - name: copy master.cf
43   copy:
44     src: "{{item}}"
45     dest: "/etc/postfix/master.cf"
46     mode: 0644
47     owner: "root"
48     group: "root"
49   with_first_found:
50     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/master.cf"
51     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/master.cf"
52     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/master.cf"
53     - "default/master.cf"
54   notify: restart postfix.service
55
56
57 - name: copy saslauthd smtpd.conf
58   copy:
59     src: "{{item}}"
60     dest: "/etc/postfix/sasl/smtpd.conf"
61     mode: 0644
62     owner: "root"
63     group: "root"
64   with_first_found:
65     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/sasl.smtpd.conf"
66     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/sasl.smtpd.conf"
67     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/sasl.smtpd.conf"
68     - "default/sasl.smtpd.conf"
69   notify: restart postfix.service
70
71
72 - name: copy header_checks_in.regexp
73   copy:
74     src: "{{item}}"
75     dest: "/etc/postfix/header_checks_in.regexp"
76     mode: 0644
77     owner: "root"
78     group: "root"
79   with_first_found:
80     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/header_checks_in.regexp"
81     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/header_checks_in.regexp"
82     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/header_checks_in.regexp"
83     - "default/header_checks_in.regexp"
84   notify: reload postfix.service
85
86
87 - name: copy header_checks_out.regexp
88   copy:
89     src: "{{item}}"
90     dest: "/etc/postfix/header_checks_out.regexp"
91     mode: 0644
92     owner: "root"
93     group: "root"
94   with_first_found:
95     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/header_checks_out.regexp"
96     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/header_checks_out.regexp"
97     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/header_checks_out.regexp"
98     - "default/header_checks_out.regexp"
99   notify: reload postfix.service
100
101
102 - name: copy rcpt_recipient.regexp
103   copy:
104     src: "{{item}}"
105     dest: "/etc/postfix/rcpt_recipient.regexp"
106     mode: 0644
107     owner: "root"
108     group: "root"
109   with_first_found:
110     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/rcpt_recipient.regexp"
111     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/rcpt_recipient.regexp"
112     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/rcpt_recipient.regexp"
113     - "default/rcpt_recipient.regexp"
114   notify: reload postfix.service
115
116
117 - name: copy rcpt_sender.regexp
118   copy:
119     src: "{{item}}"
120     dest: "/etc/postfix/rcpt_sender.regexp"
121     mode: 0644
122     owner: "root"
123     group: "root"
124   with_first_found:
125     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/rcpt_sender.regexp"
126     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/rcpt_sender.regexp"
127     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/rcpt_sender.regexp"
128     - "default/rcpt_sender.regexp"
129   notify: reload postfix.service
130
131
132 - name: copy rel_recipient.regexp
133   copy:
134     src: "{{item}}"
135     dest: "/etc/postfix/rel_recipient.regexp"
136     mode: 0644
137     owner: "root"
138     group: "root"
139   with_first_found:
140     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/rel_recipient.regexp"
141     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/rel_recipient.regexp"
142     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/rel_recipient.regexp"
143     - "default/rel_recipient.regexp"
144   notify: reload postfix.service
145
146
147 - name: copy rel_sender.regexp
148   copy:
149     src: "{{item}}"
150     dest: "/etc/postfix/rel_sender.regexp"
151     mode: 0644
152     owner: "root"
153     group: "root"
154   with_first_found:
155     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/rel_sender.regexp"
156     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/rel_sender.regexp"
157     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/rel_sender.regexp"
158     - "default/rel_sender.regexp"
159   notify: reload postfix.service
160
161
162 - name: copy transport.map
163   copy:
164     src: "{{item}}"
165     dest: "/etc/postfix/transport.map"
166     mode: 0644
167     owner: "root"
168     group: "root"
169   with_first_found:
170     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/transport.map"
171     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/transport.map"
172     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/transport.map"
173     - "default/transport.map"
174   notify: rehash postfix maps
175
176
177 - name: copy virtual.map
178   copy:
179     src: "{{item}}"
180     dest: "/etc/postfix/virtual.map"
181     mode: 0644
182     owner: "root"
183     group: "root"
184   with_first_found:
185     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/virtual.map"
186     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/virtual.map"
187     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/virtual.map"
188     - "default/virtual.map"
189   notify: rehash postfix maps
190
191
192 - name: copy postfix@.service to /etc/systemd/system/
193   copy:
194     src: "{{item}}"
195     dest: "/etc/systemd/system/postfix@.service"
196     mode: 0644
197     owner: "root"
198     group: "root"
199   with_first_found:
200     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/postfix@.service"
201     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/postfix@.service"
202     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/postfix@.service"
203     - "default/postfix@.service"
204
205
206 - name: enable and start postfix.service
207   include_role: name="base/systemd/enable-and-start"
208   vars:
209     service_name: postfix.service