Install PowerDNS with MySQL Backend (from scratch) without official Galaxy role
- Jinja 100%
| .ansible | ||
| .vscode | ||
| inventories/production | ||
| playbooks | ||
| roles/pdns | ||
| .gitignore | ||
| ansible.cfg | ||
| README.md | ||
| requirements.yml | ||
PowerDNS
Install PowerDNS with MySQL Backend (from scratch) without official Galaxy role
PowerDNS Ansible Role
Overview
This repository provides an Ansible role for automated deployment and configuration of PowerDNS with MySQL backend, including API reverse proxy setup via Nginx and optional IP whitelisting. It is designed for production environments and supports idempotent, repeatable infrastructure management.
Features
- Installs PowerDNS, MySQL, and required dependencies
- Configures MySQL authentication and database for PowerDNS
- Imports PowerDNS schema
- Sets up PowerDNS API and tests connectivity
- Configures Nginx as a secure reverse proxy for the API
- Supports IP whitelisting and SSL certificates
- Ensures services are running and enabled
- Includes handlers for service restarts
- Designed for use with Ansible inventories and group variables
Directory Structure
ansible.cfg
requirements.yml
inventories/
production/
hosts.yml
group_vars/
all.yml
playbooks/
pdns.yml
roles/
pdns/
defaults/
main.yml
handlers/
main.yml
tasks/
main.yml
nginx.yml
templates/
pdns-api.conf.j2
pdns.local.gmysql.conf.j2
Usage
- Clone this repository:
git clone <repo-url> cd PowerDNS - Install Ansible and required collections:
pip install ansible ansible-galaxy install -r requirements.yml - Configure your inventory and group variables in
inventories/production/. - Run the playbook:
ansible-playbook playbooks/pdns.yml --ask-vault-pass or ansible-playbook -i inventories/production/hosts.yml playbooks/pdns.yml --ask-vault-pass
Testing
- Verify PowerDNS service status:
bash systemctl status pdns.service - Test PowerDNS API connectivity:
bash curl --insecure -H 'X-API-Key: <your-api-key>' https://<your-domain-or-ip>:<your-port>/api/v1/servers - Example with placeholder values:
bash i.e., curl --insecure -H 'X-API-Key: xxxxxxxxxxxxxxxxxxxxxxxx' https://192.168.1.7:8080/api/v1/servers
Customization
-
Adjust variables in
group_vars/all.ymlfor database credentials, network settings, ... -
Modify templates in
roles/pdns/templates/for custom Nginx or PowerDNS configurations. -
Adjust vault file
inventories/production/group_vars/all/vault.ymlfor sensitive data.ansible-vault edit inventories/production/group_vars/all/vault.yml
Author
Christian Wirtz
Date
2025/11
Links/Source
ToDo
- Implement monitoring and alerting for PowerDNS services
- Enhance logging and auditing capabilities
- optional: Install PowerDNS Admin GUI (as container? locally?)
- optional: Setup DNSSEC for secure DNS transactions