Browse Source

Dynamic dns registration support.

pull/79/head
Martin Horak 6 years ago
parent
commit
144b32412a
6 changed files with 47 additions and 0 deletions
  1. +2
    -0
      metadata/service/minion/dns_register.yml
  2. +6
    -0
      salt/map.jinja
  3. +15
    -0
      salt/master/ddns_registrator.sls
  4. +3
    -0
      salt/master/init.sls
  5. +4
    -0
      salt/minion/dns_register.sls
  6. +17
    -0
      salt/reactor/node_ddns_register.sls

+ 2
- 0
metadata/service/minion/dns_register.yml View File

applications:
- salt.minion.dns_register

+ 6
- 0
salt/map.jinja View File

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 %}

+ 15
- 0
salt/master/ddns_registrator.sls View File

{%- 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
- 0
salt/master/init.sls View File

{%- 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

+ 4
- 0
salt/minion/dns_register.sls View File

send_dns_register_event:
event.send:
- name: dns/node/register
- net_info: {{ pillar.linux.network.get('host', {}) }}

+ 17
- 0
salt/reactor/node_ddns_register.sls View File

{%- 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 %}

Loading…
Cancel
Save