From e025ebc0c423aa7b83869de278808386cd3d2d52 Mon Sep 17 00:00:00 2001
From: Ben Nemec <bnemec@redhat.com>
Date: Thu, 5 Jul 2018 21:02:12 +0000
Subject: [PATCH] Enable configuration of Designate's pools.yaml

This is necessary as the settings in this file are deployment
specific, so the defaults will never be correct.  For simplicity,
the enablement environment includes the sample pools.yaml content
from the Designate docs.  It can then be easily modified to match
the actual intended deployment environment.

Depends-On: https://review.openstack.org/580524
Change-Id: I84cc3b06ac77c723994be0f49960a93e0dbba0ad
---
 .../scenario003-multinode-containers.yaml     | 44 +++++++++++++++++
 environments/enable-designate.yaml            | 48 +++++++++++++++++++
 puppet/services/designate-central.yaml        |  6 ++-
 sample-env-generator/enable-services.yaml     | 48 +++++++++++++++++++
 4 files changed, 145 insertions(+), 1 deletion(-)

diff --git a/ci/environments/scenario003-multinode-containers.yaml b/ci/environments/scenario003-multinode-containers.yaml
index 5a97c75fa9..2e7a23c029 100644
--- a/ci/environments/scenario003-multinode-containers.yaml
+++ b/ci/environments/scenario003-multinode-containers.yaml
@@ -88,3 +88,47 @@ parameter_defaults:
   NeutronPluginExtensions: qos,port_security,dns
   RpcPort: 31459
   NotifyPort: 5672
+  DesignatePools: |
+    - name: default
+      # The name is immutable. There will be no option to change the name after
+      # creation and the only way will to change it will be to delete it
+      # (and all zones associated with it) and recreate it.
+      description: Default Pool
+
+      attributes: {}
+
+      # List out the NS records for zones hosted within this pool
+      # This should be a record that is created outside of designate, that
+      # points to the public IP of the controller node.
+      ns_records:
+        - hostname: ns1-1.example.org.
+          priority: 1
+
+      # List out the nameservers for this pool. These are the actual BIND servers.
+      # We use these to verify changes have propagated to all nameservers.
+      nameservers:
+        - host: 127.0.0.1
+          port: 53
+
+      # List out the targets for this pool. For BIND there will be one
+      # entry for each BIND server, as we have to run rndc command on each server
+      targets:
+        - type: bind9
+          description: BIND9 Server 1
+
+          # List out the designate-mdns servers from which BIND servers should
+          # request zone transfers (AXFRs) from.
+          # This should be the IP of the controller node.
+          # If you have multiple controllers you can add multiple masters
+          # by running designate-mdns on them, and adding them here.
+          masters:
+            - host: 127.0.0.1
+              port: 5354
+
+          # BIND Configuration options
+          options:
+            host: 127.0.0.1
+            port: 53
+            rndc_host: 127.0.0.1
+            rndc_port: 953
+            rndc_key_file: /etc/rndc.key
diff --git a/environments/enable-designate.yaml b/environments/enable-designate.yaml
index 245e99d4b7..c5db29e1a7 100644
--- a/environments/enable-designate.yaml
+++ b/environments/enable-designate.yaml
@@ -13,6 +13,54 @@
 #   configuration values for other services to allow them to integrate with
 #   Designate.
 parameter_defaults:
+  # The content for Designate's pools.yaml
+  # Mandatory. This parameter must be set by the user.
+  # Type: string
+  DesignatePools: |
+    - name: default
+      # The name is immutable. There will be no option to change the name after
+      # creation and the only way will to change it will be to delete it
+      # (and all zones associated with it) and recreate it.
+      description: Default Pool
+
+      attributes: {}
+
+      # List out the NS records for zones hosted within this pool
+      # This should be a record that is created outside of designate, that
+      # points to the public IP of the controller node.
+      ns_records:
+        - hostname: ns1-1.example.org.
+          priority: 1
+
+      # List out the nameservers for this pool. These are the actual BIND servers.
+      # We use these to verify changes have propagated to all nameservers.
+      nameservers:
+        - host: 127.0.0.1
+          port: 53
+
+      # List out the targets for this pool. For BIND there will be one
+      # entry for each BIND server, as we have to run rndc command on each server
+      targets:
+        - type: bind9
+          description: BIND9 Server 1
+
+          # List out the designate-mdns servers from which BIND servers should
+          # request zone transfers (AXFRs) from.
+          # This should be the IP of the controller node.
+          # If you have multiple controllers you can add multiple masters
+          # by running designate-mdns on them, and adding them here.
+          masters:
+            - host: 127.0.0.1
+              port: 5354
+
+          # BIND Configuration options
+          options:
+            host: 127.0.0.1
+            port: 53
+            rndc_host: 127.0.0.1
+            rndc_port: 953
+            rndc_key_file: /etc/rndc.key
+
   # If True, enable the internal Neutron DNS server that provides name
   # resolution between VMs.  This parameter has no effect if
   # NeutronDhcpAgentDnsmasqDnsServers is set.
diff --git a/puppet/services/designate-central.yaml b/puppet/services/designate-central.yaml
index aaa3efd923..2b3d57433f 100644
--- a/puppet/services/designate-central.yaml
+++ b/puppet/services/designate-central.yaml
@@ -45,6 +45,9 @@ parameters:
     description: The password for the Designate's database account.
     type: string
     hidden: true
+  DesignatePools:
+    description: The content for Designate's pools.yaml
+    type: string
 
 conditions:
   designate_workers_zero: {equals : [{get_param: DesignateWorkers}, 0]}
@@ -72,7 +75,8 @@ outputs:
       config_settings:
         map_merge:
         - get_attr: [DesignateBase, role_data, config_settings]
-        - designate::db::database_connection:
+        - tripleo::profile::base::designate::central::pools_file_content: {get_param: DesignatePools}
+          designate::db::database_connection:
             make_url:
               scheme: {get_param: [EndpointMap, MysqlInternal, protocol]}
               username: designate
diff --git a/sample-env-generator/enable-services.yaml b/sample-env-generator/enable-services.yaml
index a0016037ab..9201aaee8d 100644
--- a/sample-env-generator/enable-services.yaml
+++ b/sample-env-generator/enable-services.yaml
@@ -22,6 +22,54 @@ environments:
       puppet/services/neutron-dhcp.yaml:
         parameters:
           - NeutronEnableInternalDNS
+      puppet/services/designate-central.yaml:
+        parameters:
+          - DesignatePools
     sample_values:
       NeutronPluginExtensions: qos,port_security,dns
       NeutronEnableInternalDNS: True
+      DesignatePools: |-
+        |
+            - name: default
+              # The name is immutable. There will be no option to change the name after
+              # creation and the only way will to change it will be to delete it
+              # (and all zones associated with it) and recreate it.
+              description: Default Pool
+
+              attributes: {}
+
+              # List out the NS records for zones hosted within this pool
+              # This should be a record that is created outside of designate, that
+              # points to the public IP of the controller node.
+              ns_records:
+                - hostname: ns1-1.example.org.
+                  priority: 1
+
+              # List out the nameservers for this pool. These are the actual BIND servers.
+              # We use these to verify changes have propagated to all nameservers.
+              nameservers:
+                - host: 127.0.0.1
+                  port: 53
+
+              # List out the targets for this pool. For BIND there will be one
+              # entry for each BIND server, as we have to run rndc command on each server
+              targets:
+                - type: bind9
+                  description: BIND9 Server 1
+
+                  # List out the designate-mdns servers from which BIND servers should
+                  # request zone transfers (AXFRs) from.
+                  # This should be the IP of the controller node.
+                  # If you have multiple controllers you can add multiple masters
+                  # by running designate-mdns on them, and adding them here.
+                  masters:
+                    - host: 127.0.0.1
+                      port: 5354
+
+                  # BIND Configuration options
+                  options:
+                    host: 127.0.0.1
+                    port: 53
+                    rndc_host: 127.0.0.1
+                    rndc_port: 953
+                    rndc_key_file: /etc/rndc.key