@@ -0,0 +1,2 @@ | |||
applications: | |||
- salt.minion.dns_register |
@@ -30,9 +30,13 @@ default: | |||
Arch: | |||
pkgs: | |||
- salt | |||
ddns_pkgs: | |||
- python-dnspython | |||
Debian: | |||
pkgs: | |||
- salt-master | |||
ddns_pkgs: | |||
- python-dnspython | |||
Gentoo: | |||
pkgs: | |||
- app-admin/salt | |||
@@ -42,6 +46,8 @@ MacOS: | |||
RedHat: | |||
pkgs: | |||
- salt-master | |||
ddns_pkgs: | |||
- python-dnspython | |||
{%- endload %} | |||
{%- if pillar.salt.master is defined %} |
@@ -0,0 +1,15 @@ | |||
{%- 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 %} |
@@ -3,6 +3,9 @@ include: | |||
{%- if pillar.salt.master.reactor is defined %} | |||
- salt.master.reactor | |||
{%- endif %} | |||
{%- if pillar.salt.master.ddns is defined %} | |||
- salt.master.ddns_registrator | |||
{%- endif %} | |||
- salt.master.env | |||
- salt.master.pillar | |||
- salt.master.minion |
@@ -0,0 +1,4 @@ | |||
send_dns_register_event: | |||
event.send: | |||
- name: dns/node/register | |||
- net_info: {{ pillar.linux.network.get('host', {}) }} |
@@ -0,0 +1,17 @@ | |||
{%- 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 %} |