Move dhcpd.conf preamble into a separate file.

This commit is contained in:
2021-09-12 17:35:12 +01:00
parent c9f742817b
commit 6c2ff849d6
2 changed files with 12 additions and 13 deletions

9
dhcpd.conf.head Executable file
View File

@@ -0,0 +1,9 @@
option domain-name "home.paler.net";
max-lease-time 600;
default-lease-time 600;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
range 192.168.1.100 192.168.1.200;

View File

@@ -6,19 +6,9 @@ do_curl() {
curl -s -k -H "Authorization: Token ${TOKEN}" -X GET $1 curl -s -k -H "Authorization: Token ${TOKEN}" -X GET $1
} }
cat<<EOF echo "# generated by $0 at $(date)"
# generated by $0 at $(date) echo
cat dhcpd.conf.head
option domain-name "home.paler.net";
max-lease-time 600;
default-lease-time 600;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
range 192.168.1.100 192.168.1.200;
EOF
do_curl "https://${NETBOX}/api/ipam/ip-addresses/" | \ do_curl "https://${NETBOX}/api/ipam/ip-addresses/" | \
jq -r '.results[] | .assigned_object.device.name + .assigned_object.virtual_machine.name + " " + (.address / "/")[0] + " " + .assigned_object.url' | jq -r '.results[] | .assigned_object.device.name + .assigned_object.virtual_machine.name + " " + (.address / "/")[0] + " " + .assigned_object.url' |