opendkim-config:
  file.recurse:
    - name: /etc/opendkim
    - source: salt://opendkim/config
    - user: opendkim
    - group: opendkim
    - template: jinja

opendkim-config-etc:
  file.symlink:
    - name: /etc/opendkim.conf
    - target: /etc/opendkim/opendkim.conf
    - force: True

opendkim-pid-file:
  file.absent:
    - name: /var/run/opendkim/opendkim.pid

opendkim-key:
  cmd.run:
    - name: opendkim-genkey -s dkim -d "$(cat /tmp/gcf-model.json | jq -r .model.common.mail.domain)"
    - cwd: /etc/opendkim/keys
    - creates: /etc/opendkim/keys/dkim.private

opendkim-key-owner:
  file.directory:
    - name: /etc/opendkim/keys
    - user: opendkim
    - group: opendkim
    - recurse:
      - user
      - group
