Update pools management way
In Mitaka since [1] it is recommended to use pools.yaml
file to manage pools in Designate. This commit allows
to use server.pools list from pillar to configure pools.yaml
in Mitaka and later releases. In the same time code is
backward compatible, in case server.pool variable is defined
old way for managing pools will be used.
Additional change:
make rndc.key depend on designate packages, because currently
salt fails to create it because designate packages aren't
installed yet.
[1] https://github.com/openstack/designate/commit/e612a3974fe6bb411c1a97f0b27186ef7d6c8e0d
Change-Id: Ia4b4595962cc8cf11cf976c806e0ac5217a80baf
diff --git a/designate/files/mitaka/pools.yaml b/designate/files/mitaka/pools.yaml
new file mode 100644
index 0000000..29ca0e5
--- /dev/null
+++ b/designate/files/mitaka/pools.yaml
@@ -0,0 +1,70 @@
+{%- from "designate/map.jinja" import server with context %}
+{% for pool in server.pools -%}
+- name: {{ pool.name }}
+ # 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: {{ pool.description }}
+
+ {%- if pool.attributes is defined %}
+ # Attributes are Key:Value pairs that describe the pool. for example the level
+ # of service (i.e. service_tier:GOLD), capabilities (i.e. anycast: true) or
+ # other metadata. Users can use this information to point their zones to the
+ # correct pool
+ attributes:
+ {%- for k,v in pool.attributes.items() %}
+ {{ k }}: {{ v }}
+ {%- endfor %}
+ {%- endif %}
+
+ # List out the NS records for zones hosted within this pool
+ ns_records:
+ {% for rec in pool.ns_records -%}
+ - hostname: {{ rec.hostname }}
+ priority: {{ rec.priority }}
+ {% endfor -%}
+
+ # List out the nameservers for this pool. These are the actual DNS servers.
+ # We use these to verify changes have propagated to all nameservers.
+ nameservers:
+ {% for nameserver in pool.nameservers -%}
+ - host: {{ nameserver.host }}
+ port: {{ nameserver.port }}
+ {% endfor -%}
+
+ # List out the targets for this pool. For DNS there will be one
+ # entry for each DNS server, as we have to run rndc command on each server
+ targets:
+ {% for target in pool.targets -%}
+ - type: {{ target.type }}
+ description: {{ target.description }}
+
+ # List out the designate-mdns servers from which DNS servers should
+ # request zone transfers (AXFRs) from.
+ masters:
+ {% for master in target.masters -%}
+ - host: {{ master.host }}
+ port: {{ master.port }}
+ {% endfor -%}
+
+ # DNS server Configuration options
+ options:
+ host: {{ target.options.host }}
+ port: {{ target.options.port }}
+ {%- if target.type == 'bind9' %}
+ rndc_host: {{ target.options.rndc_host }}
+ rndc_port: {{ target.options.rndc_port }}
+ rndc_key_file: {{ target.options.rndc_key_file }}
+ {%- endif %}
+ {% endfor -%}
+
+ {%- if pool.also_notifies is defined %}
+ # Optional list of additional IP/Port's for which designate-mdns will send
+ # DNS NOTIFY packets to
+ also_notifies:
+ {%- for notify in pool.also_notifies %}
+ - host: {{ notify.host }}
+ port: {{ notify.port }}
+ {%- endfor %}
+ {%- endif %}
+{%- endfor %}
diff --git a/designate/server.sls b/designate/server.sls
index 6040b0f..18b067b 100644
--- a/designate/server.sls
+++ b/designate/server.sls
@@ -1,12 +1,12 @@
{%- from "designate/map.jinja" import server with context %}
{%- if server.enabled %}
+{%- if server.backend is defined %}
+
{%- if server.backend.bind9 is defined %}
-designate_bind_packages:
- pkg.installed:
- - names:
- - bind9utils
+include:
+- bind
{%- if server.backend.bind9.rndc_key is defined %}
@@ -16,6 +16,9 @@
- template: jinja
- require:
- pkg: bind9utils
+ - pkg: designate_server_packages
+
+{%- endif %}
{%- endif %}
@@ -63,4 +66,20 @@
- watch:
- file: /etc/designate/designate.conf
+{%- if server.version not in ['liberty', 'juno', 'kilo'] and server.pools is defined %}
+# Since Mitaka it is recommended to use pools.yaml for pools configuration
+/etc/designate/pools.yaml:
+ file.managed:
+ - source: salt://designate/files/{{ server.version }}/pools.yaml
+ - template: jinja
+ - require:
+ - pkg: designate_server_packages
+
+designate_pool_update:
+ cmd.run:
+ - name: designate-manage pool update
+ - require:
+ - file: /etc/designate/pools.yaml
+ - service: designate_server_services
+{%- endif %}
{%- endif %}
diff --git a/tests/pillar/designate.sls b/tests/pillar/designate.sls
deleted file mode 100644
index 7b990da..0000000
--- a/tests/pillar/designate.sls
+++ /dev/null
@@ -1,31 +0,0 @@
-designate:
- server:
- backend:
- bind9:
- rndc_key: MqoG9BsOgQgwB5sch/oJqA==
- enabled: true
- region: RegionOne
- domain_id: 5186883b-91fb-4891-bd49-e6769234a8fc
- version: ${_param:designate_version}
- message_queue:
- members:
- - host: ${_param:messaging_node01_address}
- - host: ${_param:messaging_node02_address}
- - host: ${_param:messaging_node03_address}
- pool:
- pool_id: cae73b6f-95eb-4a7d-a567-099ae6176e08
- nameservers:
- - uuid: 690d7bc8-811b-404c-abcc-9cec54d87092
- host: ${_param:cluster_node01_address}
- port: 53
- - uuid: bc5ddcf0-8d95-4f87-b435-9ff831a4a14c
- host: ${_param:cluster_node02_address}
- port: 53
- - uuid: a43d5375-a5ec-4077-8c87-ec0b08fa3bd1
- host: ${_param:cluster_node03_address}
- port: 53
- targets:
- uuid: f26e0b32-736f-4f0a-831b-039a415c481e
- options: 'port: 53, host: 127.0.0.1'
- masters: 127.0.0.1:5354
- type: bind9
diff --git a/tests/pillar/designate_liberty.sls b/tests/pillar/designate_liberty.sls
new file mode 100644
index 0000000..be528eb
--- /dev/null
+++ b/tests/pillar/designate_liberty.sls
@@ -0,0 +1,28 @@
+designate:
+ server:
+ enabled: true
+ region: RegionOne
+ domain_id: 5186883b-91fb-4891-bd49-e6769234a8fc
+ version: liberty
+ message_queue:
+ members:
+ - host: 127.0.0.1
+ - host: 127.0.1.1
+ - host: 127.0.2.1
+ pool:
+ pool_id: cae73b6f-95eb-4a7d-a567-099ae6176e08
+ nameservers:
+ - uuid: 690d7bc8-811b-404c-abcc-9cec54d87092
+ host: 127.0.0.1
+ port: 53
+ - uuid: bc5ddcf0-8d95-4f87-b435-9ff831a4a14c
+ host: 127.0.1.1
+ port: 53
+ - uuid: a43d5375-a5ec-4077-8c87-ec0b08fa3bd1
+ host: 127.0.2.1
+ port: 53
+ targets:
+ uuid: f26e0b32-736f-4f0a-831b-039a415c481e
+ options: 'port: 53, host: 127.0.0.1'
+ masters: 127.0.0.1:5354
+ type: bind9
\ No newline at end of file
diff --git a/tests/pillar/designate_mitaka.sls b/tests/pillar/designate_mitaka.sls
new file mode 100644
index 0000000..dfa90c3
--- /dev/null
+++ b/tests/pillar/designate_mitaka.sls
@@ -0,0 +1,42 @@
+designate:
+ server:
+ enabled: true
+ region: RegionOne
+ domain_id: 5186883b-91fb-4891-bd49-e6769234a8fc
+ version: mitaka
+ message_queue:
+ members:
+ - host: 127.0.0.1
+ - host: 127.0.1.1
+ - host: 127.0.2.1
+ pools:
+ - name: default
+ description: 'default pool'
+ attributes:
+ service_tier: GOLD
+ test_attr: test_value
+ ns_records:
+ - hostname: 'ns1.example.org.'
+ priority: 10
+ nameservers:
+ - host: 127.0.0.1
+ port: 53
+ - host: 127.0.1.1
+ port: 53
+ - host: 127.0.2.1
+ port: 53
+ targets:
+ - type: bind9
+ description: 'default target'
+ masters:
+ - host: 127.0.0.1
+ port: 5354
+ options:
+ host: 127.0.0.1
+ port: 53
+ rndc_host: 127.0.0.1
+ rndc_port: 953
+ rndc_key_file: /etc/designate/rndc.key
+ also_notifies:
+ - host: 127.0.3.1
+ port: 53