Deploy YADIFA authoritative DNS server using Docker containers orchestrated by Ansible.
Note: YADIFA is an authoritative-only DNS server. It does not support recursion, caching, or forwarding. It serves authoritative zone data exclusively.
Important: There is no official YADIFA Docker image on Docker Hub. The playbook below builds a custom image from source.
ansible-galaxy collection install community.docker
---
- name: Deploy YADIFA with Docker
hosts: yadifa_servers
become: true
gather_facts: true
vars:
yadifa_version: "3.0.9"
yadifa_image: "yadifa:{{ yadifa_version }}"
yadifa_container_name: "yadifa"
yadifa_config_dir: "/opt/yadifa"
tasks:
- name: Install Docker dependencies
package:
name:
- docker
- docker-compose-plugin
state: present
- name: Ensure Docker service is running
systemd:
name: docker
state: started
enabled: true
- name: Create directories
file:
path: "{{ item }}"
state: directory
mode: '0755'
loop:
- "{{ yadifa_config_dir }}"
- "{{ yadifa_config_dir }}/config"
- "{{ yadifa_config_dir }}/zones"
- "{{ yadifa_config_dir }}/logs"
- name: Deploy Docker Compose file
template:
src: docker-compose.yml.j2
dest: "{{ yadifa_config_dir }}/docker-compose.yml"
mode: '0644'
- name: Deploy YADIFA configuration
template:
src: yadifad.conf.j2
dest: "{{ yadifa_config_dir }}/config/yadifad.conf"
mode: '0644'
notify: Restart YADIFA
- name: Start container
community.docker.docker_compose_v2:
project_src: "{{ yadifa_config_dir }}"
state: present
- name: Verify YADIFA is running
command: dig @127.0.0.1 localhost SOA +short
register: dig_result
retries: 5
delay: 3
until: dig_result.rc == 0
changed_when: false
handlers:
- name: Restart YADIFA
community.docker.docker_compose_v2:
project_src: "{{ yadifa_config_dir }}"
state: present
restarted: true
# Run the playbook
ansible-playbook -i inventory.ini site.yml
# Verify deployment
docker ps | grep yadifa
dig @127.0.0.1 localhost SOA
3.0.9), not latest:ro)NET_BIND_SERVICE only)Beyond this playbook, we offer:
Contact our automation team: office@linux-server-admin.com | Contact Page