## dhcpd.conf {% if dhcp_use_ansible_managed %}# {{ ansible_managed }}{% endif %} # Do not edit manually {% if dhcp_omapi_port is defined %} omapi-port {{ dhcp_omapi_port }}; {% endif %} # option definitions common to all supported networks... {% if dhcp_common_domain is defined %} option domain-name "{{ dhcp_common_domain }}"; {% endif %} {% if dhcp_common_nameservers is defined %} option domain-name-servers {{ dhcp_common_nameservers }}; {% endif %} {% if dhcp_common_default_lease_time is defined %} default-lease-time {{ dhcp_common_default_lease_time }}; {% endif %} {% if dhcp_common_max_lease_time is defined %} max-lease-time {{ dhcp_common_max_lease_time }}; {% endif %} # Dynamic DNS ddns-updates {{ dhcp_ddns_updates | ternary("on", "off") }}; ddns-update-style {{ dhcp_ddns_update_style }}; {{ dhcp_ddns_client_updates | ternary("allow", "ignore") }} client-updates; {{ dhcp_ddns_unknown_clients | ternary("allow", "ignore") }} unknown-clients; update-static-leases {{ dhcp_ddns_update_static_leases | ternary("on", "off") }}; {% if dhcp_ddns_keys is defined %} {% for key in dhcp_ddns_keys %} key {{ key.name }} { algorithm hmac-md5; secret {{ key.value }}; } {% endfor %} {% endif %} {% if dhcp_ddns_zones is defined %} {% for zone in dhcp_ddns_zones %} zone {{ zone.name }}. { primary {{ zone.primary }}; key {{ zone.key }}; } {% endfor %} {% endif %} {% if dhcp_common_authoritative is defined %} # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. authoritative; {% endif %} {% if dhcp_common_log_facility is defined %} # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility {{ dhcp_common_log_facility }}; {% endif %} {% if dhcp_common_options is defined %} {% if dhcp_common_enable_pxe_boot %} filename "{{ dhcp_common_pxe_boot_file }}"; next-server {{ dhcp_common_pxe_boot_server }}; {% endif %} #DHCP options {% for o in dhcp_common_options %} option {{ o }}; {% endfor %} {% endif %} {% if dhcp_common_parameters is defined %} #DHCP parameters {% for p in dhcp_common_parameters %} {{ p }}; {% endfor %} {% endif %} {% if dhcp_classes is defined %} # Classes {% for c in dhcp_classes %} class "{{ c.name }}" { {{ c.rule }}; {% if c.options is defined %} {% for i in c.options %} option {{ i.opt }}; {% endfor %} {% endif %} } {% endfor %} {% endif %} {% if dhcp_hosts is defined %} # Hosts {% for h in dhcp_hosts %} host {{ h.name }} { hardware ethernet {{ h.mac_address }}; ddns-hostname {{ h.name }}; {% if h.fixed_address is defined %} fixed-address {{ h.fixed_address }}; {% endif %} {% if h.routers is defined %} option routers {{ h.routers }}; {% endif %} {% if h.broadcast_address is defined %} option broadcast-address {{ h.broadcast_address }}; {% endif %} {% if h.domain_nameservers is defined %} option domain-name-servers {{ h.domain_nameservers }}; {% endif %} {% if h.domain_name is defined %} option domain-name "{{ h.domain_name }}"; {% endif %} {% if h.default_lease_time is defined %} default-lease-time {{ h.default_lease_time }}; {% endif %} {% if h.max_lease_time is defined %} max-lease-time {{ h.max_lease_time }}; {% endif %} {% if h.parameters is defined %} {% for p in h.parameters %} {{ p }}; {% endfor %} {% endif %} } {% endfor %} {% endif %} {% if dhcp_subnets is defined %} # Subnets {% for s in dhcp_subnets %} subnet {{ s.base }} netmask {{ s.netmask }} { {% if s.interface is defined %} interface "{{ s.interface }}"; {% endif %} {% if s.range_start is defined %} range {{ s.range_start }} {{ s.range_end }}; {% endif %} {% if s.routers is defined %} option routers {{ s.routers }}; {% endif %} {% if s.broadcast_address is defined %} option broadcast-address {{ s.broadcast_address }}; {% endif %} {% if s.domain_nameservers is defined %} option domain-name-servers {{ s.domain_nameservers }}; {% endif %} {% if s.domain_name is defined %} option domain-name "{{ s.domain_name }}"; {% endif %} {% if s.ntp_servers is defined %} option ntp-servers {{ s.ntp_servers }}; {% endif %} {% if s.default_lease_time is defined %} default-lease-time {{ s.default_lease_time }}; {% endif %} {% if s.max_lease_time is defined %} max-lease-time {{ s.max_lease_time }}; {% endif %} {% if s.pools is defined %} {% for p in s.pools %} pool { {% if p.rule is defined %} {{ p.rule }}; {% endif %} range {{ p.range_start }} {{ p.range_end }}; {% if p.parameters is defined %} {% for param in p.parameters %} {{ param }}; {% endfor %} {% endif %} } {% endfor %} {% endif %} {% if s.parameters is defined %} {% for p in s.parameters %} {{ p }}; {% endfor %} {% endif %} } {% endfor %} {% endif %} {% if dhcp_shared_networks is defined %} # Shared networks {% for n in dhcp_shared_networks %} shared-network {{ n.name }} { {% if n.interface is defined %} interface "{{ n.interface }}"; {% endif %} {% for s in n.subnets %} subnet {{ s.base }} netmask {{ s.netmask }} { {% if s.range_start is defined %} range {{ s.range_start }} {{ s.range_end }}; {% endif %} {% if s.routers is defined %} option routers {{ s.routers }}; {% endif %} {% if s.broadcast_address is defined %} option broadcast-address {{ s.broadcast_address }}; {% endif %} {% if s.domain_nameservers is defined %} option domain-name-servers {{ s.domain_nameservers }}; {% endif %} {% if s.domain_name is defined %} option domain-name "{{ s.domain_name }}"; {% endif %} {% if s.ntp_servers is defined %} option ntp-servers {{ s.ntp_servers }}; {% endif %} {% if s.default_lease_time is defined %} default-lease-time {{ s.default_lease_time }}; {% endif %} {% if s.max_lease_time is defined %} max-lease-time {{ s.max_lease_time }}; {% endif %} {% if s.pools is defined %} {% for p in s.pools %} pool { {% if p.rule is defined %} {{ p.rule }}; {% endif %} range {{ p.range_start }} {{ p.range_end }}; {% if p.parameters is defined %} {% for param in p.parameters %} {{ param }}; {% endfor %} {% endif %} } {% endfor %} {% endif %} {% if s.parameters is defined %} {% for param in s.parameters %} {{ param }}; {% endfor %} {% endif %} } {% endfor %} {% if n.pools is defined %} {% for p in n.pools %} pool { {{ p.rule }}; range {{ p.range_start }} {{ p.range_end }}; {% if p.parameters is defined %} {% for param in p.parameters %} {{ param }}; {% endfor %} {% endif %} } {% endfor %} {% endif %} {% if n.parameters is defined %} {% for p in n.parameters %} {{ p }}; {% endfor %} {% endif %} } {% endfor %} {% endif %} {% if dhcp_ifelse is defined %} # If else clauses {% for ie in dhcp_ifelse %} if {{ ie.condition }} { {{ ie.val }} }{% if ie.else is defined %}{% for e in ie.else %} else { {{ e.val }} }{% endfor %} {% endif %} {% endfor %} {% endif %}