---

- name: Ensure that the PowerDNS configuration directory exists
  file:
    name: "{{ pdns_rec_config_dir }}"
    state: directory
    owner: root
    group: root

- name: Generate the PowerDNS Recursor configuration
  template:
    src: recursor.conf.j2
    dest: "{{ pdns_rec_config_dir }}/{{ pdns_rec_config_file }}"
  notify: Restart PowerDNS Recursor

- name: Generate the Lua config-file
  copy:
    dest: "{{ pdns_rec_config_lua }}"
    content: "{{ pdns_rec_lua_config_file_content }}"
  when: pdns_rec_lua_config_file_content is defined
  notify: Restart PowerDNS Recursor

- name: Generate the Lua dns-script
  copy:
    dest: "{{ pdns_rec_config_dns_script }}"
    content: "{{ pdns_rec_lua_dns_script_content }}"
  when: pdns_rec_lua_dns_script_content is defined
  notify: Restart PowerDNS Recursor

---

- name: Ensure that the PowerDNS configuration directory exists
  file:
    name: "{{ pdns_rec_config_dir }}"
    state: directory
    owner: root
    group: root

- name: Generate the PowerDNS Recursor configuration
  template:
    src: recursor.conf.j2
    dest: "{{ pdns_rec_config_dir }}/{{ pdns_rec_config_file }}"
  notify: Restart PowerDNS Recursor

- name: Ensure that the include-dir configuration directory exists 
  file:
    name: "{{ pdns_rec_config['include-dir'] }}"
    state: directory
    owner: root
    group: root
  when: "pdns_rec_config['include-dir'] is defined" 

- name: Generate the Lua config-file
  copy:
    dest: "{{ pdns_rec_config_lua }}"
    content: "{{ pdns_rec_lua_config_file_content }}"
  when: pdns_rec_lua_config_file_content is defined
  notify: Restart PowerDNS Recursor

- name: Generate the Lua dns-script
  copy:
    dest: "{{ pdns_rec_config_dns_script }}"
    content: "{{ pdns_rec_lua_dns_script_content }}"
  when: pdns_rec_lua_dns_script_content is defined
  notify: Restart PowerDNS Recursor

Handle correctly the includ-dir option
Handle correctly the includ-dir option
