Explorar el Código

Dynamic dns registration support.

pull/79/head
Martin Horak hace 6 años
padre
commit
144b32412a
Se han modificado 6 ficheros con 47 adiciones y 0 borrados
  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 Ver fichero

@@ -0,0 +1,2 @@
applications:
- salt.minion.dns_register

+ 6
- 0
salt/map.jinja Ver fichero

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

+ 15
- 0
salt/master/ddns_registrator.sls Ver fichero

@@ -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
- 0
salt/master/init.sls Ver fichero

@@ -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

+ 4
- 0
salt/minion/dns_register.sls Ver fichero

@@ -0,0 +1,4 @@
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 Ver fichero

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

Cargando…
Cancelar
Guardar