modules: dhcp: Add an mgmt module for managing dhcpd

This is not perfect, but it's a good start, and it shows how a module
might be structured.
This commit is contained in:
James Shubin
2024-11-18 15:12:01 -05:00
parent 3bd6986fde
commit 907d2ad1a1
7 changed files with 327 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
#
# This file has been generated by mgmt config. Do not edit.
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp-server/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
#
# global option definitions
#
{{ if .domain -}}
option domain-name "{{ .domain }}";
{{ end -}}
{{ if .dns -}}
option domain-name-servers {{ .dns }};
{{ end -}}
#
# dhcpd settings
#
{{ if .omapiport -}}
#omapi-port {{ .omapiport }}; # FIXME !
{{ end -}}
{{ if .serveridentifier -}}
#server-identifier {{ .serveridentifier }}; # FIXME !
{{ end -}}
default-lease-time {{ .defaultleasetime }};
max-lease-time {{ .maxleasetime }};
# Use this to enable / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
{{ if .authoritative -}}
authoritative;
{{ else -}}
#authoritative; # not authoritative!
{{ end -}}
# 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 local7;
#
# include all the subnet definitions
#
include "/etc/dhcp/subnets.conf";
#
# include all the hosts
#
include "/etc/dhcp/hosts.conf";

View File

@@ -0,0 +1,19 @@
{{/* newline for host spacing */}}
# host: {{ .name }}
host {{ .name }} {
hardware ethernet {{ .macaddress }};
fixed-address {{ .valid_fixedaddress }};
{{- if .hostname }}
option host-name "{{ .hostname }}";
{{ end -}}
{{- if .nextserver }}
next-server {{ .nextserver }};
{{ end -}}
{{- if .filename }}
filename "{{ .filename }}";
{{ end -}}
{{- if .veo }}
filename "{{ .filename }}";
option vendor-encapsulated-options {{ .veo }};
{{ end -}}
}

View File

@@ -0,0 +1,3 @@
#
# This has been generated by mgmt config. Do not edit.
#

View File

@@ -0,0 +1,34 @@
{{/* newline for subnet spacing */}}
#
# {{ .name }} subnet
#
subnet {{ .network }} netmask {{ .netmask }} {
option subnet-mask {{ .netmask }};
{{- if .broadcast }}
option broadcast-address {{ .broadcast }};
{{ end -}}
{{- if .router }}
option routers {{ .router }};
{{ end -}}
{{- if .dns }}
option domain-name-servers {{ .dns }};
{{ end -}}
{{- if .nextserver }}
next-server {{ .nextserver }};
{{ end -}}
{{- if .filename }}
filename "{{ .filename }}";
{{ end -}}
{{- if .serveridentifier }}
server-identifier {{ .serveridentifier }};
{{ end -}}
{{- if .defaultleasetime }}
default-lease-time {{ .defaultleasetime }};
{{ end -}}
{{- if .maxleasetime }}
max-lease-time {{ .maxleasetime }};
{{ end -}}
{{- if .range }}
range {{ .range }};
{{ end -}}
}

View File

@@ -0,0 +1,3 @@
#
# This has been generated by mgmt config. Do not edit.
#