dhcp: fix templating

This commit is contained in:
Astro 2016-12-15 19:11:07 +01:00
parent f2725528cf
commit ceec7bf5db
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{%- set ifaces = [] %}
{%- for iface, ips in salt['grains.get']('ip_interfaces').items() %}
{%- if iface not in ['core', 'lo'] %}
{%- if iface not in ['core', 'lo'] and pillar['subnets-inet'].get(iface) %}
{%- set ifaces = ifaces.append(iface) %}
{%- endif %}
{%- endfor %}

View File

@ -1,7 +1,7 @@
{%- import_yaml "netmasks.yaml" as netmasks -%}
{%- for iface, ips in salt['grains.get']('ip_interfaces').items() %}
{%- if iface not in ['core', 'lo'] %}
{%- if iface not in ['core', 'lo'] and pillar['subnets-inet'].get(iface) %}
{%- set conf = pillar['dhcp'][iface] %}
{%- set subnet = pillar['subnets-inet'][iface] %}
subnet {{ subnet.split('/')[0] }} netmask {{ netmasks[subnet.split('/')[1]] }} {
@ -9,15 +9,15 @@ subnet {{ subnet.split('/')[0] }} netmask {{ netmasks[subnet.split('/')[1]] }} {
default-lease-time {{ conf['time'] }};
max-lease-time {{ conf['max-time'] }};
range {{ conf['start'] }} {{ conf['end'] }};
{%- for name, value in conf['opts'].items() %}
{%- for name, value in (conf.get('opts') or {}).items() %}
option {{ name }} {{ value }};
{%- endfor %}
{%- for name, value in conf['host-opts'].items() %}
{%- for name, value in (conf.get('host-opts') or {}).items() %}
{%- set host = value.split('.')[0] %}
{%- set net = value.split('.')[1] %}
option {{ name }} {{ pillar['hosts-inet'][net][host] }};
{%- endfor %}
{%- for name, value in conf['string-opts'].items() %}
{%- for name, value in (conf.get('string-opts') or {}).items() %}
option {{ name }} "{{ value }}";
{%- endfor %}
}