From 724d877995dfcc10c462a18dcb4ea6c8b60c2d03 Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 2 Jul 2023 19:04:30 -0400 Subject: initial commit --- roles/opendkim/tasks/main.yml | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 roles/opendkim/tasks/main.yml (limited to 'roles/opendkim/tasks') diff --git a/roles/opendkim/tasks/main.yml b/roles/opendkim/tasks/main.yml new file mode 100644 index 0000000..b56081a --- /dev/null +++ b/roles/opendkim/tasks/main.yml @@ -0,0 +1,57 @@ +- name: install packages + package: + name: + - opendkim + - opendkim-tools + state: latest + +- name: create dkimkeys directory + file: + path: /etc/dkimkeys + owner: opendkim + group: opendkim + mode: '700' + state: directory + +- name: generate opendkim key + command: + cmd: "opendkim-genkey -D /etc/dkimkeys -d {{ domain }} -s {{ dkim_selector }}" + +- name: rename dkim key file + command: "mv /etc/dkimkeys/{{ dkim_selector }}.private /etc/dkimkeys/{{ dkim_selector }}.pem" + args: + removes: "/etc/dkimkeys/{{ dkim_selector }}.private" + creates: "/etc/dkimkeys/{{ dkim_selector }}.pem" + +- name: make directory for socket inside postfix chroot + file: + path: /var/spool/postfix/opendkim + owner: opendkim + group: opendkim + mode: '770' + state: directory + +- name: add postfix user to opendkim group + user: + name: postfix + groups: opendkim + append: yes + +- name: deploy configuration + template: + src: opendkim.conf.j2 + dest: /etc/opendkim.conf + owner: root + group: root + mode: '0644' + +- name: enable opendkim + systemd: + enabled: yes + masked: no + name: opendkim + +- name: restart opendkim + service: + name: opendkim + state: restarted -- cgit v1.2.3