Commit 5f2ba344 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

software/powerdns: add multidomain support

See merge request nexedi/slapos!863
parents 4d6ce023 36211420
Pipeline #12757 failed with stage
...@@ -26,7 +26,7 @@ md5sum = 20c37ea06a8fa405bc02470d5115fd11 ...@@ -26,7 +26,7 @@ md5sum = 20c37ea06a8fa405bc02470d5115fd11
[template-dns-replicate] [template-dns-replicate]
_update_hash_filename_ = instance-powerdns-replicate.cfg.jinja2 _update_hash_filename_ = instance-powerdns-replicate.cfg.jinja2
md5sum = c2bd424f588ad57d37f4cf1329734fb6 md5sum = 72ce30bee3b8a9da8ac9be7eb65d83a2
[iso-list] [iso-list]
_update_hash_filename_ = template/zz.countries.nexedi.dk.rbldnsd _update_hash_filename_ = template/zz.countries.nexedi.dk.rbldnsd
...@@ -34,4 +34,4 @@ md5sum = c4dc8c141d81b92d92cdb82ca67a13ee ...@@ -34,4 +34,4 @@ md5sum = c4dc8c141d81b92d92cdb82ca67a13ee
[template-zones-file] [template-zones-file]
_update_hash_filename_ = template/zones-file.yml.jinja2 _update_hash_filename_ = template/zones-file.yml.jinja2
md5sum = 03037141ad1d3467ae878c9798724f70 md5sum = 612de569ac3d1e8cc10b830683ff92ae
...@@ -33,12 +33,12 @@ ...@@ -33,12 +33,12 @@
"default": "", "default": "",
"type": "string" "type": "string"
}, },
"zone": { "supported-zone-list": {
"title": "Zone", "title": "Zone",
"description": "Zone to be handled by the DNS cluster", "description": "Zone to be handled by the DNS cluster",
"type": "string", "type": "string",
"default": "domain.com", "default": "domain.com",
"pattern": "^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$" "pattern": "^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}(\\s([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6})*$"
}, },
"server-admin": { "server-admin": {
"title": "Zone Administrator Email", "title": "Zone Administrator Email",
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
"title": "DNS domains template string", "title": "DNS domains template string",
"description": "Template used to generate DNS domain name", "description": "Template used to generate DNS domain name",
"type": "string", "type": "string",
"default": "ns%s. + zone" "default": "ns%s.domain.com"
}, },
"monitor-interface-url": { "monitor-interface-url": {
"title": "Monitor Web Interface URL", "title": "Monitor Web Interface URL",
......
...@@ -33,9 +33,9 @@ context = ...@@ -33,9 +33,9 @@ context =
{% endif -%} {% endif -%}
## DNS set up ## DNS set up
{% set zone = slapparameter_dict.pop('zone', 'domain.com') %} {%- set supported_zone_list = slapparameter_dict.pop('supported-zone-list', 'domain.com').split() %}
{% set server_admin = slapparameter_dict.pop('server-admin', 'admin@domain.com') %} {% set server_admin = slapparameter_dict.pop('server-admin', 'admin@domain.com') %}
{% set dns_name_template_string = slapparameter_dict.pop('dns-name-template-string', 'ns%s.' + zone) %} {% set dns_name_template_string = slapparameter_dict.pop('dns-name-template-string', 'ns%s.domain.com') %}
# Here we request individualy each dns. # Here we request individualy each dns.
# The presence of sla parameters is checked and added if found # The presence of sla parameters is checked and added if found
...@@ -65,7 +65,7 @@ name = {{dns_name}} ...@@ -65,7 +65,7 @@ name = {{dns_name}}
{% if state_key in slapparameter_dict %} {% if state_key in slapparameter_dict %}
state = {{ slapparameter_dict.pop(state_key) }} state = {{ slapparameter_dict.pop(state_key) }}
{% endif%} {% endif%}
config-zone = {{ zone }} config-supported-zone-list = {{ ' '.join(supported_zone_list) }}
config-soa = {{ "%s,%s" % (dns_domain, server_admin) }} config-soa = {{ "%s,%s" % (dns_domain, server_admin) }}
{% for parameter in sla_parameters -%} {% for parameter in sla_parameters -%}
sla-{{ parameter }} = {{ slapparameter_dict.pop( sla_key + parameter ) }} sla-{{ parameter }} = {{ slapparameter_dict.pop( sla_key + parameter ) }}
...@@ -74,11 +74,9 @@ sla-{{ parameter }} = {{ slapparameter_dict.pop( sla_key + parameter ) }} ...@@ -74,11 +74,9 @@ sla-{{ parameter }} = {{ slapparameter_dict.pop( sla_key + parameter ) }}
[{{promise_section_title}}] [{{promise_section_title}}]
<= monitor-promise-base <= monitor-promise-base
module = check_port_listening module = check_port_listening
name = pdns-port-listening.py name = {{promise_section_title}}.py
{% set ipv6 = '${' ~ request_section_title ~ ':connection-powerdns-ipv6}' -%} config-hostname = {{ '${' ~ request_section_title ~ ':connection-powerdns-ipv6}' }}
config-hostname = {{ipv6}} config-port = {{ '${' ~ request_section_title ~ ':connection-powerdns-port}' }}
{% set port = '${' ~ request_section_title ~ ':connection-powerdns-port}' -%}
config-port = {{port}}
{% do monitor_url_list.append('${' ~ request_section_title ~ ':connection-monitor-base-url}') -%} {% do monitor_url_list.append('${' ~ request_section_title ~ ':connection-monitor-base-url}') -%}
{% endfor -%} {% endfor -%}
......
...@@ -8,6 +8,13 @@ ...@@ -8,6 +8,13 @@
"description": "Record for the configuration", "description": "Record for the configuration",
"type": "string" "type": "string"
}, },
"applicable-zone": {
"title": "Applicable Zone",
"description": "Zone to which this record belongs. You can put only one zone here. If the record belongs to several zones, you should create several slaves.",
"pattern": "^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$",
"default": "domain.com",
"type": "string"
},
"origin": { "origin": {
"title": "Origin", "title": "Origin",
"description": "Used to qualify RR in the configuration. i.e.: if your origin is a.example.com and the RR for Europe is 'eu' the european clients will use eu.a.example.com", "description": "Used to qualify RR in the configuration. i.e.: if your origin is a.example.com and the RR for Europe is 'eu' the european clients will use eu.a.example.com",
......
# See https://doc.powerdns.com/authoritative/backends/geoip.html # See https://doc.powerdns.com/authoritative/backends/geoip.html
{%- set slave_instance_list = json_module.loads(slapparameter_dict.get('extra_slave_instance_list', '[]')) %} {%- set slave_instance_list = json_module.loads(slapparameter_dict.get('extra_slave_instance_list', '[]')) %}
{%- set zone = slapparameter_dict.get('zone', 'example.com') %} {%- set supported_zone_list = slapparameter_dict.get('supported-zone-list', 'example.com').split() %}
{%- macro disambiguate_domain_name(a, b) %} {%- macro disambiguate_domain_name(a, b) %}
{#- See http://www.dns-sd.org/trailingdotsindomainnames.html #} {#- See http://www.dns-sd.org/trailingdotsindomainnames.html #}
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
{%- endmacro %} {%- endmacro %}
domains: domains:
{%- for zone in supported_zone_list %}
- domain: {{ zone }} - domain: {{ zone }}
# TODO: what value for ttl? # TODO: what value for ttl?
ttl: 300 ttl: 300
...@@ -48,6 +50,7 @@ domains: ...@@ -48,6 +50,7 @@ domains:
{%- for slave in slave_instance_list %} {%- for slave in slave_instance_list %}
{%- if slave['applicable-zone'] == zone %}
{%- set origin = slave['origin'] %} {%- set origin = slave['origin'] %}
{%- set unique_slave_id = slave['slave_reference'] %} {%- set unique_slave_id = slave['slave_reference'] %}
{#- Set the RR to use for each region, as described in {#- Set the RR to use for each region, as described in
...@@ -77,13 +80,15 @@ domains: ...@@ -77,13 +80,15 @@ domains:
- cname: {{ disambiguate_domain_name(rr_dict[region], origin) }} - cname: {{ disambiguate_domain_name(rr_dict[region], origin) }}
{%- endfor %} {%- endfor %}
{%- endfor %} {%- endfor %}
{%- endif %}
{%- endfor %} {%- endfor %}
services: services:
{%- for slave in slave_instance_list %} {%- for slave in slave_instance_list %}
{%- if slave['applicable-zone'] == zone %}
{%- set origin = slave['origin'] %} {%- set origin = slave['origin'] %}
{%- set unique_slave_id = slave['slave_reference'] %} {%- set unique_slave_id = slave['slave_reference'] %}
{{ disambiguate_domain_name(slave['record'], zone) }}: {{ disambiguate_domain_name(slave['record'], slave['applicable-zone']) }}:
{#- Note: Placeholders (i.e. "country." and "continent.") are used to avoid {#- Note: Placeholders (i.e. "country." and "continent.") are used to avoid
possible name collisions, e.g.: possible name collisions, e.g.:
- %cc for American Samoa is 'as' - %cc for American Samoa is 'as'
...@@ -94,4 +99,6 @@ domains: ...@@ -94,4 +99,6 @@ domains:
{%- for ip_range, country_code in china %} {%- for ip_range, country_code in china %}
{{ ip_range }}: {{ country_code }}.country.{{ unique_slave_id }} {{ ip_range }}: {{ country_code }}.country.{{ unique_slave_id }}
{%- endfor %} {%- endfor %}
{%- endif %}
{%- endfor %} {%- endfor %}
{%- endfor %}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment