Install PowerDNS with MySQL Backend (from scratch) without official Galaxy role
Find a file
2025-11-14 09:56:09 +01:00
.ansible Add initial Ansible configuration and PowerDNS role setup 2025-11-11 19:15:44 +01:00
.vscode Update PowerDNS configuration: set Python interpreter path, add API allowed IPs, and configure Nginx reverse proxy with SSL 2025-11-13 13:08:55 +01:00
inventories/production Update PowerDNS version to 50 in configuration 2025-11-14 01:25:14 +01:00
playbooks Update PowerDNS version to 50 in configuration 2025-11-14 01:25:14 +01:00
roles/pdns Update PowerDNS API bind host to localhost and clarify task comments 2025-11-14 09:47:09 +01:00
.gitignore Initial commit 2025-11-11 18:53:33 +01:00
ansible.cfg Change remote_user in ansible.cfg from ubuntu to root 2025-11-11 19:41:02 +01:00
README.md Refactor customization section in README.md for clarity and remove redundancy 2025-11-14 09:56:09 +01:00
requirements.yml Add Ansible tasks to install community.mysql collection and create requirements file 2025-11-12 01:37:25 +01:00

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

  1. Clone this repository:
    git clone <repo-url>
    cd PowerDNS
    
  2. Install Ansible and required collections:
    pip install ansible
    ansible-galaxy install -r requirements.yml
    
  3. Configure your inventory and group variables in inventories/production/.
  4. 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.yml for 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.yml for 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