aboutsummaryrefslogtreecommitdiffstats
path: root/roles/mail/tasks/dkim-genkey.yml
blob: 467a5b95b36bede7da6b1d98c90d2c3bbad3d277 (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
---
- set_fact:
    domain_keyfile: "{{ playbook_dir }}/private/dkim/{{ domain }}-{{ mail.dkim.selector }}.pem"

- name: (local) dkim - check domain private key existence
  become: false
  stat:
    path: "{{ domain_keyfile }}"
  delegate_to: localhost
  register: stat_result

- name: (local) dkim - generate domain private key
  become: false
  command: >
    openssl genrsa 
    -out "{{ domain_keyfile }}" "{{ mail.dkim.bits }}"
  delegate_to: localhost
  when: not stat_result.stat.exists

- name: dkim - copy domain private key
  copy:
    src: "{{ domain_keyfile }}"
    dest: /usr/local/etc/mail/dkim/{{ domain_keyfile | basename }}
    group: mailnull
    mode: 0440