---
- name: Install gnupg
  pacman: name=gnupg state=present

- name: Enable gpg-agent.socket
  systemd: name=gpg-agent.socket user=yes enabled=yes state=started
  become: yes
  become_user: "{{ user.name }}"
  environment:
    XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
  when: gnupg.enable_agent == True

- name: Enable dirmngr.socket
  systemd: name=dirmngr.socket user=yes enabled=yes state=started
  become: yes
  become_user: "{{ user.name }}"
  environment:
    XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
  when: gnupg.enable_agent == True

- name: Enable gpg-agent-ssh.socket
  systemd: name=gpg-agent-ssh.socket user=yes enabled=yes state=started
  become: yes
  become_user: "{{ user.name }}"
  environment:
    XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
  when: gnupg.enable_agent == True and gnupg.emulate_ssh == True
