bind-formula
bind-formula copied to clipboard
Dynamic zone and managed zone files
Hi,
Is there anyway to not erase existing records in a zone file ? We use dynamic records, so each time we run salt, the zone file is reseted
Best regards,
In this formula all records are from pillar. This means each time the formula is run it will remove anything not in pillar anymore, so if you're adding things into the zonefile by some other method than salt they will get removed on the next state run.
The only way I can see this potentially working is to have the ability to add an $INCLUDE
directive which points to a file not managed by salt. This however isn't supported by the current formula.
Perhaps we can only add a parameter on the available_zones "dynamic: True" (default to False) that will set the parameter "replace=False" on the file.managed zones ?
Also I think we can add a dependency on the service if there are some included files :
bind_restart:
service.running:
- name: {{ map.service }}
- reload: False
- watch:
- file: {{ map.chroot_dir }}{{ map.log_dir }}/query.log
- file: bind_key_directory
{% if salt['pillar.get']('bind.config.includes', []) %}
- require:
{% for included_file in salt['pillar.get']('bind.config.includes', []) %}
- file: {{ included_file }}
{% endfor %}
{% endif %}
Managing whole files with a tool like Salt and adding records dynamically, if definitelly not something that will end well :yum:
The solution I think would work for you is to add a state (dynamic.sls
?) to manage the records in the zone using the ddns state. In this case, you can declare a zone in the pillar, with your 'static' records in the zone, and add them through the dynamic.sls
state.
Obviously, those zone files should be exclusivelly populated/managed with that state, but I think it's doable. WDYT?