Ver código fonte

Finished ddns registrator via saltmaster

pull/79/head
Martin Horak 6 anos atrás
pai
commit
ecaf8ade66
5 arquivos alterados com 18 adições e 10 exclusões
  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 Ver arquivo

@@ -0,0 +1,6 @@
{%- 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 Ver arquivo

@@ -1,14 +1,13 @@
{%- 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:
- names: {{ master:ddns_pkgs }}
- names: {{ master.ddns_pkgs }}

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


+ 1
- 1
salt/master/init.sls Ver arquivo

@@ -4,7 +4,7 @@ include:
- salt.master.reactor
{%- endif %}
{%- if pillar.salt.master.ddns is defined %}
- salt.master.ddns_registrator
- salt.master.ddns
{%- endif %}
- salt.master.env
- salt.master.pillar

+ 1
- 0
salt/minion/dns_register.sls Ver arquivo

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

+ 6
- 4
salt/reactor/node_ddns_register.sls Ver arquivo

@@ -1,3 +1,4 @@
{%- set ddns = data.data.get('ddns', {}) %}
{%- 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) %}
@@ -7,11 +8,12 @@ ddns_node_register_{{ name }}_{{ loop.index }}:
- args:
- zone: {{ domain }}
- name: {{ hostname }}
- ttl: 300
- ttl: {{ ddns.get('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') }}
- 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'
- timeout: 10
{%- endfor %}
{%- endfor %}

Carregando…
Cancelar
Salvar