Skip to content
Snippets Groups Projects
Commit 2a09fc8c authored by Christian Elberfeld's avatar Christian Elberfeld
Browse files

ddns updates nach updates der zone erzwingen

parent c13b8087
No related branches found
No related tags found
1 merge request!148Umbau von PiHole auf Kea DHCP und Bind
...@@ -2,14 +2,10 @@ ...@@ -2,14 +2,10 @@
- include_tasks: ../functions/get_secret.yml - include_tasks: ../functions/get_secret.yml
with_items: with_items:
- { path: "/etc/kea/kea_api_password", length: 22 }
- { path: "/etc/kea/kea_ddns_key", length: 44 } - { path: "/etc/kea/kea_ddns_key", length: 44 }
- name: "Create new zonefile serial"
set_fact:
zonefile_serial: "{{ ansible_date_time.date | replace('-', '') }}01"
- name: "Instaliere debian Pakete" - name: "Instaliere debian Pakete"
apt: apt:
update_cache: yes update_cache: yes
...@@ -36,9 +32,59 @@ ...@@ -36,9 +32,59 @@
- named.conf.options - named.conf.options
- name: enable and restart named.service - name: "Purge DDNS Updates"
ansible.builtin.file:
path: /etc/bind/db.warpzone.lan.jnl
state: absent
- name: "Enable and restart named.service"
systemd: systemd:
name: "named.service" name: "named.service"
state: restarted state: restarted
enabled: True enabled: True
- name: "Get all active leases from Kea"
uri:
url: "http://127.0.0.1:8000"
method: POST
user: "kea-api"
password: "{{ kea_api_password }}"
body_format: json
body:
command: "lease4-get-all"
service: ["dhcp4"]
headers:
Content-Type: "application/json"
register: all_leases
- name: "Display number of leases found"
debug:
msg: "Found {{ all_leases.json[0].arguments.leases | length }} active leases"
- name: "Force DDNS update for each lease"
uri:
url: "http://127.0.0.1:8000"
method: POST
user: "kea-api"
password: "{{ kea_api_password }}"
body_format: json
body:
command: "lease4-resend-ddns"
service: ["dhcp4"]
arguments:
ip-address: "{{ item['ip-address'] }}"
headers:
Content-Type: "application/json"
loop: "{{ all_leases.json[0].arguments.leases }}"
register: ddns_results
when:
- all_leases.json[0].arguments.leases is defined
- item.hostname is defined
- item.hostname != ""
- item['ip-address'] is defined
- item['ip-address'] != ""
...@@ -11,6 +11,48 @@ apply Service "warpfire-admin" { ...@@ -11,6 +11,48 @@ apply Service "warpfire-admin" {
assign where host.name == "warpfire" assign where host.name == "warpfire"
} }
apply Service "dhcpinfo-web" {
import "generic-service"
check_command = "http"
enable_perfdata = false
vars.http_address = "$host.address$"
vars.http_port = 80
assign where host.name == "dhcpdns"
}
apply Service "dhcpinfo-connected" {
import "generic-service"
check_command = "check_metric_value"
enable_perfdata = true
vars.metric_url = "http://{{ hostvars['dhcpdns'].int_ip4 }}/metrics"
vars.metric_name = "kea_connection_ok"
vars.metric_operator = "lt"
vars.metric_warn = "1"
vars.metric_crit = "1"
assign where host.name == "dhcpdns"
}
apply Service "dhcpinfo-leases" {
import "generic-service"
check_command = "check_metric_value"
enable_perfdata = true
vars.metric_url = "http://{{ hostvars['dhcpdns'].int_ip4 }}/metrics"
vars.metric_name = "kea_total_leases"
vars.metric_operator = "lt"
vars.metric_warn = "25"
vars.metric_crit = "1"
assign where host.name == "dhcpdns"
}
apply Service "wz-uplink-globe" { apply Service "wz-uplink-globe" {
import "generic-service" import "generic-service"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment