aboutsummaryrefslogtreecommitdiff
path: root/roles/opendkim/tasks/main.yml
blob: b56081a901a08106b24f8be06edc39edc0905c92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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