Make nut ups monitoring work
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
#This file is written by ansible. Manual changes will be reverted. 2.2018, pet
|
|
||||||
|
|
||||||
|
|
||||||
KERNEL=="ttyS0", GROUP="nut"
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#This file is written by ansible. Manual changes will be reverted. 2.2018, pet
|
|
||||||
|
|
||||||
#This is the master server for the UPS, all others should be netclient.
|
|
||||||
MODE=netserver
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#This file is written by ansible. Manual changes will be reverted. 2.2018, pet
|
|
||||||
|
|
||||||
[VSD1500]
|
|
||||||
driver = riello_ser
|
|
||||||
port = /dev/ttyS1
|
|
||||||
desc = "Riello VSD 1500; RS-Components: 869-5016; bought: 1.2018"
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#This file is written by ansible. Manual changes will be reverted. 2.2018, pet
|
|
||||||
|
|
||||||
LISTEN 192.168.86.116 3493
|
|
||||||
LISTEN 127.0.0.1 3493
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#This file is written by ansible. Manual changes will be reverted. 2.2018, pet
|
|
||||||
|
|
||||||
[monmaster]
|
|
||||||
password = DorsAz4BK7XiMKDfPj
|
|
||||||
upsmon master
|
|
||||||
|
|
||||||
|
|
||||||
[monuser]
|
|
||||||
password = sEfguPcZbn99qnnTUj
|
|
||||||
upsmon slave
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#This file is written by ansible. Manual changes will be reverted. 2.2018, pet
|
|
||||||
|
|
||||||
MONITOR VSD1500@lxc-pet-01 1 monmaster DorsAz4BK7XiMKDfPj master
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
- name: Check NUT (Network UPS Tools) installation
|
|
||||||
apt:
|
|
||||||
update_cache: yes
|
|
||||||
name: nut
|
|
||||||
|
|
||||||
- name: NUT mode - /etc/nut/nut.conf
|
|
||||||
copy:
|
|
||||||
dest: /etc/nut/nut.conf
|
|
||||||
src: nut.conf
|
|
||||||
owner: root
|
|
||||||
group: nut
|
|
||||||
mode: 0640
|
|
||||||
backup: yes
|
|
||||||
|
|
||||||
- name: UPS conf - /etc/nut/ups.conf
|
|
||||||
copy:
|
|
||||||
dest: /etc/nut/ups.conf
|
|
||||||
src: ups.conf
|
|
||||||
owner: root
|
|
||||||
group: nut
|
|
||||||
mode: 0640
|
|
||||||
backup: yes
|
|
||||||
|
|
||||||
- name: UPS ip:port - /etc/nut/upsd.conf
|
|
||||||
copy:
|
|
||||||
dest: /etc/nut/upsd.conf
|
|
||||||
src: upsd.conf
|
|
||||||
owner: root
|
|
||||||
group: nut
|
|
||||||
mode: 0640
|
|
||||||
backup: yes
|
|
||||||
|
|
||||||
- name: NUT user - /etc/nut/upsd.users
|
|
||||||
copy:
|
|
||||||
dest: /etc/nut/upsd.users
|
|
||||||
src: upsd.users
|
|
||||||
owner: root
|
|
||||||
group: nut
|
|
||||||
mode: 0640
|
|
||||||
backup: yes
|
|
||||||
|
|
||||||
- name: NUT monitoring - /etc/nut/upsmon.conf
|
|
||||||
copy:
|
|
||||||
dest: /etc/nut/upsmon.conf
|
|
||||||
src: upsmon.conf
|
|
||||||
owner: root
|
|
||||||
group: nut
|
|
||||||
mode: 0640
|
|
||||||
backup: yes
|
|
||||||
|
|
||||||
#- name: Serial port configuration- /etc/udev/rules.d/99_nut-serialups.rules
|
|
||||||
# copy:
|
|
||||||
# dest: /etc/udev/rules.d/99_nut-serialups.rules
|
|
||||||
# src: 99_nut-serialups.rules
|
|
||||||
# owner: root
|
|
||||||
# group: nut
|
|
||||||
# mode: 0640
|
|
||||||
# backup: yes
|
|
||||||
#
|
|
||||||
#- name: Force udev to reload Serialports
|
|
||||||
# command: "udevadm control --reload-rules"
|
|
||||||
#
|
|
||||||
#- name: Force udev to reload Serialports
|
|
||||||
# command: "udevadm trigger"
|
|
||||||
|
|
||||||
- name: Stop the upsd
|
|
||||||
command: "upsd -c stop"
|
|
||||||
|
|
||||||
- name: Start the upsd
|
|
||||||
command: upsd
|
|
||||||
8
roles/ups/defaults/main.yml
Normal file
8
roles/ups/defaults/main.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
ups_desc: "Riello VSD 1500 from RS-Components(869-5016) installed in 2018_01"
|
||||||
|
ups_type: VSD1500
|
||||||
|
ups_drv: riello_ser
|
||||||
|
ups_port: /etc/nut/ttyUSB0
|
||||||
|
ups_port_dev: 188 0
|
||||||
|
|
||||||
|
ups_master_pw: Noongaig1quor9Waepe9
|
||||||
|
ups_slave_pw:
|
||||||
3
roles/ups/files/99_nut-serialups.rules
Normal file
3
roles/ups/files/99_nut-serialups.rules
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
KERNEL=="ttyS0", GROUP="nut"
|
||||||
2
roles/ups/handlers/main.yml
Normal file
2
roles/ups/handlers/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- name: restart nut
|
||||||
|
service: name=nut-server state=restarted
|
||||||
70
roles/ups/tasks/main.yml
Normal file
70
roles/ups/tasks/main.yml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
- name: nut - install
|
||||||
|
apt: name=nut
|
||||||
|
|
||||||
|
- name: nut - port access device
|
||||||
|
command: mknod {{ ups_port }} c {{ ups_port_dev }} creates={{ ups_port }}
|
||||||
|
notify:
|
||||||
|
restart nut
|
||||||
|
|
||||||
|
- name: nut - port access file
|
||||||
|
file: path={{ ups_port }} owner=root group=nut mode=0660
|
||||||
|
notify:
|
||||||
|
restart nut
|
||||||
|
|
||||||
|
- name: nut - default
|
||||||
|
template: dest=/etc/default/nut src=nut.j2 owner=root group=root mode=0644
|
||||||
|
notify:
|
||||||
|
restart nut
|
||||||
|
|
||||||
|
- name: nut - nut.conf
|
||||||
|
template: dest=/etc/nut/nut.conf src=nut.conf.j2 owner=root group=nut mode=0640
|
||||||
|
notify:
|
||||||
|
restart nut
|
||||||
|
|
||||||
|
- name: nut - ups.conf
|
||||||
|
template: dest=/etc/nut/ups.conf src=ups.conf.j2 owner=root group=nut mode=0640
|
||||||
|
notify:
|
||||||
|
restart nut
|
||||||
|
|
||||||
|
- name: nut - upsd.conf
|
||||||
|
template: dest=/etc/nut/upsd.conf src=upsd.conf.j2 owner=root group=nut mode=0640
|
||||||
|
notify:
|
||||||
|
restart nut
|
||||||
|
|
||||||
|
- name: nut - upsd.users
|
||||||
|
template: dest=/etc/nut/upsd.users src=upsd.users.j2 owner=root group=nut mode=0640
|
||||||
|
notify:
|
||||||
|
restart nut
|
||||||
|
|
||||||
|
- name: nut - upsmon.conf
|
||||||
|
template: dest=/etc/nut/upsmon.conf src=upsmon.conf.j2 owner=root group=nut mode=0640
|
||||||
|
notify:
|
||||||
|
restart nut
|
||||||
|
|
||||||
|
- name: nut - upssched folder
|
||||||
|
file: path=/etc/nut/upssched owner=root group=nut mode=0750 state=directory
|
||||||
|
|
||||||
|
- name: nut - upsscript
|
||||||
|
template: dest=/etc/nut/upssched/upsscript src=upsscript.j2 owner=root group=nut mode=0750
|
||||||
|
notify:
|
||||||
|
restart nut
|
||||||
|
|
||||||
|
- name: nut - upssched.conf
|
||||||
|
template: dest=/etc/nut/upssched.conf src=upssched.conf.j2 owner=root group=nut mode=0640
|
||||||
|
notify:
|
||||||
|
restart nut
|
||||||
|
|
||||||
|
#- name: Serial port configuration- /etc/udev/rules.d/99_nut-serialups.rules
|
||||||
|
# copy:
|
||||||
|
# dest: /etc/udev/rules.d/99_nut-serialups.rules
|
||||||
|
# src: 99_nut-serialups.rules
|
||||||
|
# owner: root
|
||||||
|
# group: nut
|
||||||
|
# mode: 0640
|
||||||
|
# backup: yes
|
||||||
|
#
|
||||||
|
#- name: Force udev to reload Serialports
|
||||||
|
# command: "udevadm control --reload-rules"
|
||||||
|
#
|
||||||
|
#- name: Force udev to reload Serialports
|
||||||
|
# command: "udevadm trigger"
|
||||||
5
roles/ups/templates/nut.conf.j2
Normal file
5
roles/ups/templates/nut.conf.j2
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
# /etc/nut/nut.conf
|
||||||
|
|
||||||
|
MODE=netserver
|
||||||
8
roles/ups/templates/nut.j2
Normal file
8
roles/ups/templates/nut.j2
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
# /etc/default/nut
|
||||||
|
|
||||||
|
START_UPSD=yes
|
||||||
|
UPSD_OPTIONS=""
|
||||||
|
START_UPSMON=yes
|
||||||
|
UPSMON_OPTIONS=""
|
||||||
8
roles/ups/templates/ups.conf.j2
Normal file
8
roles/ups/templates/ups.conf.j2
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
# /etc/nut/ups.conf
|
||||||
|
|
||||||
|
[{{ ups_type }}]
|
||||||
|
driver = {{ ups_drv }}
|
||||||
|
port = {{ ups_port }}
|
||||||
|
desc = {{ ups_desc }}
|
||||||
6
roles/ups/templates/upsd.conf.j2
Normal file
6
roles/ups/templates/upsd.conf.j2
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
# /etc/nut/upsd.conf
|
||||||
|
|
||||||
|
LISTEN 127.0.0.1 3493
|
||||||
|
LISTEN ::1 3493
|
||||||
12
roles/ups/templates/upsd.users.j2
Normal file
12
roles/ups/templates/upsd.users.j2
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
# /etc/nut/upsd.users
|
||||||
|
|
||||||
|
[master]
|
||||||
|
password = {{ ups_master_pw }}
|
||||||
|
upsmon master
|
||||||
|
{% if ups_slave_pw -%}
|
||||||
|
[slave]
|
||||||
|
password = {{ ups_slave_pw }}
|
||||||
|
upsmon slave
|
||||||
|
{% endif %}
|
||||||
7
roles/ups/templates/upsmon.conf.j2
Normal file
7
roles/ups/templates/upsmon.conf.j2
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
# /etc/nut/upsmon.conf
|
||||||
|
|
||||||
|
MONITOR {{ ups_type }}@localhost 1 master {{ ups_master_pw }} master
|
||||||
|
NOTIFYCMD /sbin/upssched
|
||||||
|
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
|
||||||
10
roles/ups/templates/upssched.conf.j2
Normal file
10
roles/ups/templates/upssched.conf.j2
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
# /etc/nut/upssched.conf
|
||||||
|
|
||||||
|
CMDSCRIPT /etc/nut/upssched/upsscript
|
||||||
|
PIPEFN /etc/nut/upssched/upssched.pipe
|
||||||
|
LOCKFN /etc/nut/upssched/upssched.lock
|
||||||
|
AT ONBATT * START-TIMER onbatt 120
|
||||||
|
AT ONLINE * CANCEL-TIMER onbatt
|
||||||
|
AT LOWBATT * EXEC lowbatt
|
||||||
14
roles/ups/templates/upsscript.j2
Normal file
14
roles/ups/templates/upsscript.j2
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
# /etc/nut/upssched/upsscript
|
||||||
|
|
||||||
|
#! /bin/sh
|
||||||
|
case $1 in
|
||||||
|
onbatt)
|
||||||
|
ssh
|
||||||
|
;;
|
||||||
|
lowbatt)
|
||||||
|
/sbin/upssched fsd;;
|
||||||
|
*)
|
||||||
|
echo "wrong Parameter";;
|
||||||
|
esac
|
||||||
Reference in New Issue
Block a user