applications: | |||||
- salt.minion.dns_register |
Arch: | Arch: | ||||
pkgs: | pkgs: | ||||
- salt | - salt | ||||
ddns_pkgs: | |||||
- python-dnspython | |||||
Debian: | Debian: | ||||
pkgs: | pkgs: | ||||
- salt-master | - salt-master | ||||
ddns_pkgs: | |||||
- python-dnspython | |||||
Gentoo: | Gentoo: | ||||
pkgs: | pkgs: | ||||
- app-admin/salt | - app-admin/salt | ||||
RedHat: | RedHat: | ||||
pkgs: | pkgs: | ||||
- salt-master | - salt-master | ||||
ddns_pkgs: | |||||
- python-dnspython | |||||
{%- endload %} | {%- endload %} | ||||
{%- if pillar.salt.master is defined %} | {%- if pillar.salt.master is defined %} |
{%- from "salt/map.jinja" import master with context %} | |||||
{%- if master.get('ddns:server', False) %} | |||||
ddns_registrator_packages: | |||||
pkg.installed: | |||||
- names: {{ master:ddns_pkgs }} | |||||
ddns_keys_file: | |||||
file.managed: | |||||
- name: /etc/salt/ddns.keyring | |||||
- source: salt://salt/files/ddns.keys | |||||
- template: jinja | |||||
- mode: 600 | |||||
{%- endif %} |
{%- if pillar.salt.master.reactor is defined %} | {%- if pillar.salt.master.reactor is defined %} | ||||
- salt.master.reactor | - salt.master.reactor | ||||
{%- endif %} | {%- endif %} | ||||
{%- if pillar.salt.master.ddns is defined %} | |||||
- salt.master.ddns_registrator | |||||
{%- endif %} | |||||
- salt.master.env | - salt.master.env | ||||
- salt.master.pillar | - salt.master.pillar | ||||
- salt.master.minion | - salt.master.minion |
send_dns_register_event: | |||||
event.send: | |||||
- name: dns/node/register | |||||
- net_info: {{ pillar.linux.network.get('host', {}) }} |
{%- for rec_name, record in data.data.get('net_info', {}).iteritems() %} | |||||
{%- for name in record.get('names', []) if '.' in name %} | |||||
{%- set hostname, domain = name.split('.',1) %} | |||||
ddns_node_register_{{ name }}_{{ loop.index }}: | |||||
runner.ddns.add_host: | |||||
- args: | |||||
- zone: {{ domain }} | |||||
- name: {{ hostname }} | |||||
- ttl: 300 | |||||
- ip: {{ record.get('address', '127.0.0.127') }} | |||||
- keyname: salt-updates | |||||
- keyfile: /etc/salt/dns.keyring | |||||
- nameserver: {{ salt['grains.get']('ddns_server', '127.0.0.1') }} | |||||
- keyalgorithm: 'HMAC-MD5.SIG-ALG.REG.INT' | |||||
{%- endfor %} | |||||
{%- endfor %} |