Browse Source

Finished ddns registrator via saltmaster

pull/79/head
Martin Horak 6 years ago
parent
commit
ecaf8ade66
5 changed files with 18 additions and 10 deletions
  1. +6
    -0
      salt/files/ddns.keyring
  2. +4
    -5
      salt/master/ddns.sls
  3. +1
    -1
      salt/master/init.sls
  4. +1
    -0
      salt/minion/dns_register.sls
  5. +6
    -4
      salt/reactor/node_ddns_register.sls

+ 6
- 0
salt/files/ddns.keyring View File

{%- from "salt/map.jinja" import master with context -%}
{
{%- for key in master.ddns.get('keys', []) %}
"{{ key.name }}.": "{{ key.key }}"{{ "," if not loop.last else "" }}
{%- endfor %}
}

salt/master/ddns_registrator.sls → salt/master/ddns.sls View File

{%- from "salt/map.jinja" import master with context %} {%- from "salt/map.jinja" import master with context %}
{%- if master.get('ddns:server', False) %}

ddns_registrator_packages:
{%- if master.get('ddns', {}).get('enabled', False) %}
ddns_packages:
pkg.installed: pkg.installed:
- names: {{ master:ddns_pkgs }}
- names: {{ master.ddns_pkgs }}


ddns_keys_file: ddns_keys_file:
file.managed: file.managed:
- name: /etc/salt/ddns.keyring - name: /etc/salt/ddns.keyring
- source: salt://salt/files/ddns.keys
- source: salt://salt/files/ddns.keyring
- template: jinja - template: jinja
- mode: 600 - mode: 600



+ 1
- 1
salt/master/init.sls View File

- salt.master.reactor - salt.master.reactor
{%- endif %} {%- endif %}
{%- if pillar.salt.master.ddns is defined %} {%- if pillar.salt.master.ddns is defined %}
- salt.master.ddns_registrator
- salt.master.ddns
{%- endif %} {%- endif %}
- salt.master.env - salt.master.env
- salt.master.pillar - salt.master.pillar

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

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

+ 6
- 4
salt/reactor/node_ddns_register.sls View File

{%- set ddns = data.data.get('ddns', {}) %}
{%- for rec_name, record in data.data.get('net_info', {}).iteritems() %} {%- for rec_name, record in data.data.get('net_info', {}).iteritems() %}
{%- for name in record.get('names', []) if '.' in name %} {%- for name in record.get('names', []) if '.' in name %}
{%- set hostname, domain = name.split('.',1) %} {%- set hostname, domain = name.split('.',1) %}
- args: - args:
- zone: {{ domain }} - zone: {{ domain }}
- name: {{ hostname }} - name: {{ hostname }}
- ttl: 300
- ttl: {{ ddns.get('ttl', 300) }}
- ip: {{ record.get('address', '127.0.0.127') }} - 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') }}
- keyname: {{ ddns.get('keyname', 'salt-updates') }}
- keyfile: /etc/salt/ddns.keyring
- nameserver: {{ ddns.get('server', '127.0.0.1') }}
- keyalgorithm: 'HMAC-MD5.SIG-ALG.REG.INT' - keyalgorithm: 'HMAC-MD5.SIG-ALG.REG.INT'
- timeout: 10
{%- endfor %} {%- endfor %}
{%- endfor %} {%- endfor %}

Loading…
Cancel
Save