From c88f8e6374bdb03c2fbffe107b85564a3c9b6be4 Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Sun, 20 Apr 2025 16:21:25 +0000 Subject: [PATCH] Get IP cameras from LDAP --- group_vars/frigate.yml | 2 ++ roles/dhcpd/templates/dhcpd.conf.cam.j2 | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/group_vars/frigate.yml b/group_vars/frigate.yml index f22e3ef..81a93e1 100644 --- a/group_vars/frigate.yml +++ b/group_vars/frigate.yml @@ -16,6 +16,8 @@ unbound_zones: - 26.20.172.in-addr.arpa - cam.foo.sh dhcpd_template: dhcpd.conf.cam.j2 +dhcpd_ldap_filter: >- + (&(objectClass=ieee802Device)(objectClass=ipHost)(cn=*.cam.foo.sh)) firewall_in: - {proto: tcp, port: 22, from: [172.20.20.0/22]} diff --git a/roles/dhcpd/templates/dhcpd.conf.cam.j2 b/roles/dhcpd/templates/dhcpd.conf.cam.j2 index edddc1a..54eff12 100644 --- a/roles/dhcpd/templates/dhcpd.conf.cam.j2 +++ b/roles/dhcpd/templates/dhcpd.conf.cam.j2 @@ -29,10 +29,12 @@ shared-network CAMNET { use-host-decl-names on; } - host ipcam01.cam.foo.sh { - option host-name "ipcam01.cam.foo.sh"; - hardware ethernet ec:71:db:6e:bc:0f; - fixed-address 172.20.26.101; +{% for host in ldap_hosts.results %} + host {{ host['cn'] }} { + option host-name "{{ host['cn'] }}"; + hardware ethernet {{ host['macAddress'] }}; + fixed-address {{ host['ipHostNumber'] }}; } +{% endfor %} }