From a018f64c497bfb8fbfc638737662a8fd9e680109 Mon Sep 17 00:00:00 2001
From: Andrea Dell'Amico <adellam@isti.cnr.it>
Date: Tue, 8 May 2018 18:52:04 +0200
Subject: [PATCH] Install the powerdns db backend when requested only. Add a
 role that installs the db schema. Configure the db server.

---
 powerdns-authoritative/defaults/main.yml | 5 ++++-
 powerdns-authoritative/tasks/main.yml    | 5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/powerdns-authoritative/defaults/main.yml b/powerdns-authoritative/defaults/main.yml
index 20ed933..4b20cee 100644
--- a/powerdns-authoritative/defaults/main.yml
+++ b/powerdns-authoritative/defaults/main.yml
@@ -5,7 +5,6 @@ powerdns_auth_version: '{{ powerdns_auth_major }}.{{ powerdns_auth_minor }}'
 powerdns_auth_repo_data: 'deb [arch=amd64] http://repo.powerdns.com/ubuntu {{ ansible_distribution_release }}-auth-{{ powerdns_auth_major }}{{ powerdns_auth_minor }} main'
 powerdns_auth_repo_key: 'https://repo.powerdns.com/FD380FBB-pub.asc'
 
-powerdns_auth_db_backend: pgsql
 powerdns_auth_enable_api: True
 powerdns_auth_enable_web_interface: True
 
@@ -15,5 +14,9 @@ powerdns_auth_pkgs:
   - pdns-backend-lua
   - pdns-backend-remote 
   - pdns-backend-pipe 
+
+powerdns_auth_use_db_backend: True
+powerdns_auth_db_backend: pgsql
+powerdns_auth_db_pkgs:
   - 'pdns-backend-{{ powerdns_auth_db_backend }}'
 
diff --git a/powerdns-authoritative/tasks/main.yml b/powerdns-authoritative/tasks/main.yml
index 67e4500..f588871 100644
--- a/powerdns-authoritative/tasks/main.yml
+++ b/powerdns-authoritative/tasks/main.yml
@@ -10,6 +10,11 @@
     apt: pkg={{ item }} state=present
     with_items: '{{ powerdns_auth_pkgs }}'
 
+  - name: Install the powerdns DB backend packages
+    apt: pkg={{ item }} state=present
+    with_items: '{{ powerdns_auth_db_pkgs }}'
+    when: powerdns_auth_use_db_backend
+
   - name: Ensure that powerdns is running and enabled
     service: name=pdns state=started enabled=yes