From be84734ee6cd5d0524f4a87d8ffbbfe70caa67ac Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Mon, 10 Apr 2023 21:25:17 +0200 Subject: [PATCH] feat: adjustments to nut --- hosts.yml | 1 + roles/nut/tasks/upsd.yml | 8 +++++++- roles/nut/tasks/upsmon.yml | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hosts.yml b/hosts.yml index 50a2991..79f83c0 100644 --- a/hosts.yml +++ b/hosts.yml @@ -206,6 +206,7 @@ all: serial: "GBULZ2000030" vendor: "CPS" bus: "001" + pollinterval: 15 nut_mode: netserver nut_admin_password: !vault | diff --git a/roles/nut/tasks/upsd.yml b/roles/nut/tasks/upsd.yml index 6e80831..92d6d0f 100644 --- a/roles/nut/tasks/upsd.yml +++ b/roles/nut/tasks/upsd.yml @@ -6,12 +6,18 @@ - nut-server when: ansible_distribution in ["Debian", "Ubuntu"] +- name: "set MAXAGE to 25 in /etc/nut/upsd.conf" + lineinfile: + dest: /etc/nut/upsd.conf + regexp: '^#\s*MAXAGE.*$' + line: 'MAXAGE 25' + - name: add UPS device(s) config to /etc/nut/ups.conf blockinfile: path: /etc/nut/ups.conf block: | [{{ nut_device.name }}] - {% for key, value in nut_device.config.items() %} {{ key }} = "{{ value }}" + {% for key, value in nut_device.config.items() %} {{ key }} = {{ value | to_json }} {% endfor %} - name: set up NUT user(s) to /etc/nut/upsd.users diff --git a/roles/nut/tasks/upsmon.yml b/roles/nut/tasks/upsmon.yml index 78498dd..b6885ad 100644 --- a/roles/nut/tasks/upsmon.yml +++ b/roles/nut/tasks/upsmon.yml @@ -11,6 +11,12 @@ block: | MONITOR {{ nut_device.name }}@{{ nut_host }} 1 upsmon {{ nut_upsmon_password }} {{ nut_types[nut_mode] }} +- name: "set DEADTIME to 25 in /etc/nut/upsmon.conf" + lineinfile: + dest: /etc/nut/upsmon.conf + regexp: 'DEADTIME.*$' + line: 'DEADTIME 25' + - name: start and enable nut-upsmon with openrc service: name: nut-upsmon