- name: Installer bind9
  apt:
    name: bind9
    state: present

- name: Créer les dossiers /etc/bind/{zones,catalog}
  file:
    path: "/etc/bind/{{ item }}"
    owner: bind
    group: bind
    state: directory
  loop: [ "zones", "catalog" ]

- name: Générer la config du serveur
  template:
    src: ../files/named.conf.local.j2
    dest: /etc/bind/named.conf.local
  notify: reload bind

- name: Configuration de la zone principale
  template:
    src: ../files/main.zone.j2
    dest: "/etc/bind/zones/{{ hostname }}.db"
