servers/roles/dnsmasq/templates/10-ranges.conf.j2

19 lines
979 B
Plaintext
Raw Normal View History

2024-07-26 08:13:59 +00:00
{% for prefix in prefixes | selectattr('custom_fields.dhcp_server') %}
{% if prefix.custom_fields.dhcp_server.address | ipaddr('address') == primary_ip4 %}
# {{ prefix.vlan.name }}
dhcp-range = set:{{ prefix.vlan.name }},{{ prefix.prefix | ipmath(100) }},{{ prefix.prefix | ipmath(200) }},{{ prefix.prefix | ipaddr('netmask') }}
{% if prefix.custom_fields.gateway %}
dhcp-option = tag:{{ prefix.vlan.name }},option:router,{{ prefix.custom_fields.gateway.address | ipaddr('address') }}
{% endif -%}
{% for host in hostvars.values() | selectattr('primary_ip4') | selectattr('primary_ip4', 'ansible.utils.in_network', prefix.prefix) %}
{% for interface in host.interfaces | selectattr('mac_address') %}
{% for address in interface.ip_addresses | selectattr('status.value', '==', 'dhcp') %}
dhcp-host = {{ interface.mac_address | lower }},{{ address.address | ipaddr('address') }},{{ interface.device.name | lower }}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
{% endfor %}