Commit cfece124 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

powerdns: fix for several slaves with same origin

the name of constructed records should be unique so use the slave
reference instead of the "origin" parameter to be sure it is unique.

Before this change, if 2 slaves have the same origin parameter
"foo.com", we have the following in zone-files.yml:

    [...]
    sa.continent.foo.com:
      - cname: cname.of.slave1.for.sa
    [...]
    sa.continent.foo.com:
      - cname: cname.of.slave2.for.sa

So only the cname for slave2 will be used.
parent da6b4b56
...@@ -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 = c820a4f53c3e7706f51a5e0be3a8cf74 md5sum = 03037141ad1d3467ae878c9798724f70
...@@ -48,6 +48,8 @@ domains: ...@@ -48,6 +48,8 @@ domains:
{%- for slave in slave_instance_list %} {%- for slave in slave_instance_list %}
{%- set origin = slave['origin'] %}
{%- 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
'slave-instance-powerdns-input-schema.json' #} 'slave-instance-powerdns-input-schema.json' #}
{%- set rr_dict = {} %} {%- set rr_dict = {} %}
...@@ -71,8 +73,7 @@ domains: ...@@ -71,8 +73,7 @@ domains:
right RR (thanks to 'rr_dict') #} right RR (thanks to 'rr_dict') #}
{%- for placeholder, code2region in world_split.items() %} {%- for placeholder, code2region in world_split.items() %}
{%- for code, region in code2region.items() %} {%- for code, region in code2region.items() %}
{%- set origin = slave['origin'] %} {{ code }}.{{ placeholder }}.{{ unique_slave_id }}:
{{ code }}.{{ placeholder }}.{{ origin }}:
- cname: {{ disambiguate_domain_name(rr_dict[region], origin) }} - cname: {{ disambiguate_domain_name(rr_dict[region], origin) }}
{%- endfor %} {%- endfor %}
{%- endfor %} {%- endfor %}
...@@ -81,15 +82,16 @@ domains: ...@@ -81,15 +82,16 @@ domains:
services: services:
{%- for slave in slave_instance_list %} {%- for slave in slave_instance_list %}
{%- set origin = slave['origin'] %} {%- set origin = slave['origin'] %}
{%- set unique_slave_id = slave['slave_reference'] %}
{{ disambiguate_domain_name(slave['record'], zone) }}: {{ disambiguate_domain_name(slave['record'], 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'
- %cn for Asia is also 'as' #} - %cn for Asia is also 'as' #}
default: ['%cc.country.{{ origin }}', '%cn.continent.{{ origin }}', '{{ disambiguate_domain_name(slave['default'], origin) }}'] default: ['%cc.country.{{ unique_slave_id }}', '%cn.continent.{{ unique_slave_id }}', '{{ disambiguate_domain_name(slave['default'], origin) }}']
# Split China's ip addresses according to ISP # Split China's ip addresses according to ISP
{%- for ip_range, country_code in china %} {%- for ip_range, country_code in china %}
{{ ip_range }}: {{ country_code }}.country.{{ origin }} {{ ip_range }}: {{ country_code }}.country.{{ unique_slave_id }}
{%- endfor %} {%- endfor %}
{%- endfor %} {%- endfor %}
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