2023-07-22 22:53:56 +00:00
|
|
|
---
|
|
|
|
- name: Install and update OpenDKIM
|
|
|
|
ansible.builtin.package:
|
|
|
|
name:
|
|
|
|
- opendkim
|
|
|
|
- opendkim-tools
|
2023-08-10 23:04:40 +00:00
|
|
|
state: present
|
2023-07-22 22:53:56 +00:00
|
|
|
|
|
|
|
- name: Configure OpenDKIM
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: opendkim.conf.j2
|
|
|
|
dest: /etc/opendkim.conf
|
|
|
|
notify: restart opendkim
|
|
|
|
|
|
|
|
- name: Ensure OpenDKIM unix socket path for postfix
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: /var/spool/postfix/opendkim
|
|
|
|
state: directory
|
|
|
|
owner: postfix
|
|
|
|
group: opendkim
|
|
|
|
mode: '0770'
|
|
|
|
notify: restart opendkim
|
|
|
|
|
|
|
|
- name: Generate DKIM signing key
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: "opendkim-genkey -r -s {{ dkim_selector }} -b 2048 -d {{ postfix_domain }} --directory /etc/dkimkeys"
|
|
|
|
creates: "/etc/dkimkeys/{{ dkim_selector }}.private"
|
|
|
|
become: true
|
|
|
|
become_user: opendkim
|
2023-08-10 23:17:02 +00:00
|
|
|
notify: restart opendkim
|
2023-07-22 22:53:56 +00:00
|
|
|
|
|
|
|
- name: Ensure postfix is in opendkim group
|
|
|
|
ansible.builtin.user:
|
|
|
|
name: postfix
|
|
|
|
groups: opendkim
|
|
|
|
append: true
|
2023-08-10 23:17:02 +00:00
|
|
|
notify: restart opendkim
|
|
|
|
|
|
|
|
- name: Register whether /var/spool/postfix/opendkim/opendkim.sock exists
|
|
|
|
ansible.builtin.stat:
|
|
|
|
path: /var/spool/postfix/opendkim/opendkim.sock
|
|
|
|
register: opendkim_socket
|
|
|
|
|
|
|
|
- name: (Workaround) Force opendkim to restart again if the unix socket is still missing.
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: opendkim
|
|
|
|
state: restarted
|
|
|
|
when: not opendkim_socket.stat.exists
|
2023-08-21 16:20:49 +00:00
|
|
|
|
|
|
|
- name: Ensure opendkim service is started and enabled.
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: opendkim
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
|
2023-08-10 23:17:02 +00:00
|
|
|
|