This guide provides a full Ansible playbook to install YADIFA with distro-aware package handling for Debian 12+ and Ubuntu 22.04+ systems.
Note for RHEL users: YADIFA is not available in RHEL repositories. The playbook below handles Debian/Ubuntu only. For RHEL 9+, AlmaLinux, or Rocky Linux, you must build from source.
- name: Install YADIFA
hosts: yadifa
become: true
vars:
dns_config_dir: /etc/yadifa
dns_zones_dir: /var/lib/yadifa/zones
dns_log_dir: /var/log/yadifa
tasks:
- name: Install YADIFA package (Debian/Ubuntu)
apt:
name:
- yadifa
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Create configuration directory
file:
path: "{{ dns_config_dir }}"
state: directory
mode: "0755"
owner: yadifa
group: yadifa
- name: Create zones directory
file:
path: "{{ dns_zones_dir }}"
state: directory
mode: "0755"
owner: yadifa
group: yadifa
- name: Create log directory
file:
path: "{{ dns_log_dir }}"
state: directory
mode: "0755"
owner: yadifa
group: yadifa
- name: Enable and start YADIFA service
systemd:
name: yadifa
state: started
enabled: true
daemon_reload: true
- name: Verify binary is available
command: "yadifad --version"
register: yadifa_version
changed_when: false
failed_when: false
- name: Show detected version output
debug:
var: yadifa_version.stdout
For RHEL 9+, AlmaLinux 9+, and Rocky Linux 9+, use this source build playbook:
- name: Build and install YADIFA from source (RHEL 9+)
hosts: yadifa_rhel
become: true
vars:
yadifa_version: "3.0.2"
yadifa_download_url: "https://downloads.yadifa.eu/releases"
tasks:
- name: Install build dependencies
dnf:
name:
- "@Development Tools"
- gcc
- make
- openssl-devel
- lmdb-devel
- libxml2-devel
- autoconf
- automake
- libtool
state: present
update_cache: true
- name: Download YADIFA source
get_url:
url: "{{ yadifa_download_url }}/yadifa-{{ yadifa_version }}.tar.gz"
dest: "/tmp/yadifa-{{ yadifa_version }}.tar.gz"
mode: "0644"
- name: Extract source archive
unarchive:
src: "/tmp/yadifa-{{ yadifa_version }}.tar.gz"
dest: /tmp
remote_src: true
creates: "/tmp/yadifa-{{ yadifa_version }}"
- name: Bootstrap build system
command: "./bootstrap.sh"
args:
chdir: "/tmp/yadifa-{{ yadifa_version }}"
creates: "/tmp/yadifa-{{ yadifa_version }}/configure"
- name: Configure build
command: "./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var"
args:
chdir: "/tmp/yadifa-{{ yadifa_version }}"
creates: "/tmp/yadifa-{{ yadifa_version }}/Makefile"
- name: Build YADIFA
command: "make"
args:
chdir: "/tmp/yadifa-{{ yadifa_version }}"
creates: "/tmp/yadifa-{{ yadifa_version }}/yadifad"
- name: Install YADIFA
command: "make install"
args:
chdir: "/tmp/yadifa-{{ yadifa_version }}"
become: true
- name: Create yadifa system user
user:
name: yadifa
system: true
shell: /usr/sbin/nologin
create_home: false
- name: Create required directories
file:
path: "{{ item }}"
state: directory
mode: "0755"
owner: yadifa
group: yadifa
loop:
- /etc/yadifa
- /var/lib/yadifa/zones
- /var/log/yadifa
- name: Install systemd unit file
copy:
dest: /etc/systemd/system/yadifa.service
mode: "0644"
content: |
[Unit]
Description=YADIFA Domain Name Server
Documentation=man:yadifad(8)
After=network.target
[Service]
Type=simple
ExecStart=/usr/sbin/yadifad --nodaemon -c /etc/yadifa/yadifad.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
User=yadifa
Group=yadifa
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
[Install]
WantedBy=multi-user.target
notify: reload systemd
- name: Enable and start YADIFA service
systemd:
name: yadifa
state: started
enabled: true
daemon_reload: true
handlers:
- name: reload systemd
systemd:
daemon_reload: true
yadifa (not yadifad)./etc/yadifa/yadifad.conf (note the d in yadifad.conf).We develop tailored automation solutions for:
Let’s discuss your requirements: office@linux-server-admin.com | Contact