name: <tsig-key-name> | name: <tsig-key-name> | ||||
reactor: | reactor: | ||||
dns/node/register: | dns/node/register: | ||||
- salt://salt/reactor/node_ddns_register.sls | |||||
- salt://salt/reactor/ddns_node_register.sls | |||||
dns/static/records: | |||||
- salt://salt/reactor/ddns_static_records.sls | |||||
Minion pillar: | Minion pillar: | ||||
server: <dns-server-ip> | server: <dns-server-ip> | ||||
keyname: <tsig-key-name> | keyname: <tsig-key-name> | ||||
ttl: 300 | ttl: 300 | ||||
dns_static: | |||||
zone.example.com: | |||||
- name: appname | |||||
type: CNAME | |||||
value: appserver01 | |||||
Minions can be registered in DNS calling: | |||||
.. code-block:: bash | |||||
Manual calling: | |||||
.. code-block:: bash | |||||
# Minion register | |||||
salt '*' state.apply salt.minion.dns_register | salt '*' state.apply salt.minion.dns_register | ||||
# Static DNS records | |||||
salt '*' state.apply salt.minion.dns_static | |||||
Salt Minion | Salt Minion | ||||
----------- | ----------- |
applications: | |||||
- salt.minion.dns_static |
send_dns_static_event: | |||||
event.send: | |||||
- name: dns/static/records | |||||
- records: {{ pillar.salt.minion.get('dns_static', {}) }} | |||||
- ddns: {{ pillar.salt.minion.get('ddns', {}) }} |
{%- endif %} | {%- endif %} | ||||
{%- if pillar.salt.minion.env_vars is defined %} | {%- if pillar.salt.minion.env_vars is defined %} | ||||
- salt.minion.env_vars | - salt.minion.env_vars | ||||
{%- if pillar.salt.minion.ddns is defined %} | |||||
- salt.minion.dns_register | |||||
{%- if pillar.salt.minion.dns_static is defined %} | |||||
- salt.minion.dns_static | |||||
{%- endif %} | |||||
{%- endif %} | {%- endif %} |
{%- set ddns = data.data.get('ddns', {}) %} | |||||
{%- for zone_name, zone in data.data.get('records', {}).iteritems() %} | |||||
{%- for record in zone %} | |||||
ddns_update_{{ zone_name }}_{{ loop.index }}: | |||||
runner.ddns.update: | |||||
- args: | |||||
- zone: {{ zone_name }} | |||||
- name: {{ record['name'] }} | |||||
- ttl: {{ ddns.get('ttl', 300) }} | |||||
- rdtype: {{ record['type'] }} | |||||
- data: {{ record['value'] }} | |||||
- keyname: {{ ddns.get('keyname', 'salt-updates') }} | |||||
- keyfile: /etc/salt/ddns.keyring | |||||
- nameserver: {{ ddns.get('server', '127.0.0.1') }} | |||||
- timeout: 10 | |||||
- replace: True | |||||
- keyalgorithm: 'HMAC-MD5.SIG-ALG.REG.INT' | |||||
{%- endfor %} | |||||
{%- endfor %} |