---
- name: Include tasks for Debian/Ubuntu
  include_tasks: ubuntu.yml
  when: is_debian_based

- name: dnscrypt-proxy ip-blacklist configured
  template:
    src: ip-blacklist.txt.j2
    dest: "{{ config_prefix | default('/') }}etc/dnscrypt-proxy/ip-blacklist.txt"
    mode: '0644'
  notify:
    - restart dnscrypt-proxy

- name: dnscrypt-proxy configured
  template:
    src: dnscrypt-proxy.toml.j2
    dest: "{{ config_prefix | default('/') }}etc/dnscrypt-proxy/dnscrypt-proxy.toml"
    mode: '0644'
  notify:
    - restart dnscrypt-proxy

- name: Include DNS adblocking tasks
  import_tasks: dns_adblocking.yml
  when: algo_dns_adblocking

- meta: flush_handlers

- name: Ensure dnscrypt-proxy socket is enabled and started
  systemd:
    name: dnscrypt-proxy.socket
    enabled: true
    state: started
    daemon_reload: true
  when: uses_systemd_socket

- name: dnscrypt-proxy enabled and started
  service:
    name: dnscrypt-proxy
    state: started
    enabled: true
