mirror of
https://github.com/mdlayher/homelab.git
synced 2024-12-15 17:50:54 +00:00
apcupsd: initial commit
This commit is contained in:
parent
78166d55f5
commit
fb20966e0d
5 changed files with 218 additions and 0 deletions
28
roles/apcupsd/tasks/main.yml
Normal file
28
roles/apcupsd/tasks/main.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- name: install apcupsd
|
||||
tags:
|
||||
- apcupsd
|
||||
apt:
|
||||
pkg: apcupsd
|
||||
state: installed
|
||||
|
||||
- name: create apcupsd configuration
|
||||
tags:
|
||||
- apcupsd
|
||||
template:
|
||||
src: apcupsd.conf.j2
|
||||
dest: "/etc/apcupsd/apcupsd.conf"
|
||||
|
||||
- name: set apcupsd as configured
|
||||
tags:
|
||||
- apcupsd
|
||||
template:
|
||||
src: apcupsd.j2
|
||||
dest: "/etc/default/apcupsd"
|
||||
|
||||
- name: restart apcupsd
|
||||
tags:
|
||||
- apcupsd
|
||||
service:
|
||||
name: apcupsd
|
||||
state: restarted
|
181
roles/apcupsd/templates/apcupsd.conf.j2
Normal file
181
roles/apcupsd/templates/apcupsd.conf.j2
Normal file
|
@ -0,0 +1,181 @@
|
|||
## apcupsd.conf v1.1 ##
|
||||
# {{ ansible_managed }}
|
||||
|
||||
# USB UPS configuration only.
|
||||
UPSCABLE usb
|
||||
UPSTYPE usb
|
||||
|
||||
# POLLTIME <int>
|
||||
# Interval (in seconds) at which apcupsd polls the UPS for status. This
|
||||
# setting applies both to directly-attached UPSes (UPSTYPE apcsmart, usb,
|
||||
# dumb) and networked UPSes (UPSTYPE net, snmp). Lowering this setting
|
||||
# will improve apcupsd's responsiveness to certain events at the cost of
|
||||
# higher CPU utilization. The default of 60 is appropriate for most
|
||||
# situations.
|
||||
POLLTIME 20
|
||||
|
||||
# LOCKFILE <path to lockfile>
|
||||
# Path for device lock file. Not used on Win32.
|
||||
LOCKFILE /var/lock
|
||||
|
||||
# SCRIPTDIR <path to script directory>
|
||||
# Directory in which apccontrol and event scripts are located.
|
||||
SCRIPTDIR /etc/apcupsd
|
||||
|
||||
# PWRFAILDIR <path to powerfail directory>
|
||||
# Directory in which to write the powerfail flag file. This file
|
||||
# is created when apcupsd initiates a system shutdown and is
|
||||
# checked in the OS halt scripts to determine if a killpower
|
||||
# (turning off UPS output power) is required.
|
||||
PWRFAILDIR /etc/apcupsd
|
||||
|
||||
# NOLOGINDIR <path to nologin directory>
|
||||
# Directory in which to write the nologin file. The existence
|
||||
# of this flag file tells the OS to disallow new logins.
|
||||
NOLOGINDIR /etc
|
||||
|
||||
|
||||
#
|
||||
# ======== Configuration parameters used during power failures ==========
|
||||
#
|
||||
|
||||
# The ONBATTERYDELAY is the time in seconds from when a power failure
|
||||
# is detected until we react to it with an onbattery event.
|
||||
#
|
||||
# This means that, apccontrol will be called with the powerout argument
|
||||
# immediately when a power failure is detected. However, the
|
||||
# onbattery argument is passed to apccontrol only after the
|
||||
# ONBATTERYDELAY time. If you don't want to be annoyed by short
|
||||
# powerfailures, make sure that apccontrol powerout does nothing
|
||||
# i.e. comment out the wall.
|
||||
ONBATTERYDELAY 6
|
||||
|
||||
#
|
||||
# Note: BATTERYLEVEL, MINUTES, and TIMEOUT work in conjunction, so
|
||||
# the first that occurs will cause the initation of a shutdown.
|
||||
#
|
||||
|
||||
# If during a power failure, the remaining battery percentage
|
||||
# (as reported by the UPS) is below or equal to BATTERYLEVEL,
|
||||
# apcupsd will initiate a system shutdown.
|
||||
BATTERYLEVEL 5
|
||||
|
||||
# If during a power failure, the remaining runtime in minutes
|
||||
# (as calculated internally by the UPS) is below or equal to MINUTES,
|
||||
# apcupsd, will initiate a system shutdown.
|
||||
MINUTES 3
|
||||
|
||||
# If during a power failure, the UPS has run on batteries for TIMEOUT
|
||||
# many seconds or longer, apcupsd will initiate a system shutdown.
|
||||
# A value of 0 disables this timer.
|
||||
#
|
||||
# Note, if you have a Smart UPS, you will most likely want to disable
|
||||
# this timer by setting it to zero. That way, you UPS will continue
|
||||
# on batteries until either the % charge remaing drops to or below BATTERYLEVEL,
|
||||
# or the remaining battery runtime drops to or below MINUTES. Of course,
|
||||
# if you are testing, setting this to 60 causes a quick system shutdown
|
||||
# if you pull the power plug.
|
||||
# If you have an older dumb UPS, you will want to set this to less than
|
||||
# the time you know you can run on batteries.
|
||||
TIMEOUT 0
|
||||
|
||||
# Time in seconds between annoying users to signoff prior to
|
||||
# system shutdown. 0 disables.
|
||||
ANNOY 300
|
||||
|
||||
# Initial delay after power failure before warning users to get
|
||||
# off the system.
|
||||
ANNOYDELAY 60
|
||||
|
||||
# The condition which determines when users are prevented from
|
||||
# logging in during a power failure.
|
||||
# NOLOGON <string> [ disable | timeout | percent | minutes | always ]
|
||||
NOLOGON disable
|
||||
|
||||
# If KILLDELAY is non-zero, apcupsd will continue running after a
|
||||
# shutdown has been requested, and after the specified time in
|
||||
# seconds attempt to kill the power. This is for use on systems
|
||||
# where apcupsd cannot regain control after a shutdown.
|
||||
# KILLDELAY <seconds> 0 disables
|
||||
KILLDELAY 0
|
||||
|
||||
#
|
||||
# ==== Configuration statements for Network Information Server ====
|
||||
#
|
||||
|
||||
# NETSERVER [ on | off ] on enables, off disables the network
|
||||
# information server. If netstatus is on, a network information
|
||||
# server process will be started for serving the STATUS and
|
||||
# EVENT data over the network (used by CGI programs).
|
||||
NETSERVER on
|
||||
|
||||
# NISIP <dotted notation ip address>
|
||||
# IP address on which NIS server will listen for incoming connections.
|
||||
# This is useful if your server is multi-homed (has more than one
|
||||
# network interface and IP address). Default value is 0.0.0.0 which
|
||||
# means any incoming request will be serviced. Alternatively, you can
|
||||
# configure this setting to any specific IP address of your server and
|
||||
# NIS will listen for connections only on that interface. Use the
|
||||
# loopback address (127.0.0.1) to accept connections only from the
|
||||
# local machine.
|
||||
NISIP 127.0.0.1
|
||||
|
||||
# NISPORT <port> default is 3551 as registered with the IANA
|
||||
# port to use for sending STATUS and EVENTS data over the network.
|
||||
# It is not used unless NETSERVER is on. If you change this port,
|
||||
# you will need to change the corresponding value in the cgi directory
|
||||
# and rebuild the cgi programs.
|
||||
NISPORT 3551
|
||||
|
||||
# If you want the last few EVENTS to be available over the network
|
||||
# by the network information server, you must define an EVENTSFILE.
|
||||
EVENTSFILE /var/log/apcupsd/apcupsd.events
|
||||
|
||||
# EVENTSFILEMAX <kilobytes>
|
||||
# By default, the size of the EVENTSFILE will be not be allowed to exceed
|
||||
# 10 kilobytes. When the file grows beyond this limit, older EVENTS will
|
||||
# be removed from the beginning of the file (first in first out). The
|
||||
# parameter EVENTSFILEMAX can be set to a different kilobyte value, or set
|
||||
# to zero to allow the EVENTSFILE to grow without limit.
|
||||
EVENTSFILEMAX 10
|
||||
|
||||
#
|
||||
# ========== Configuration statements used if sharing =============
|
||||
# a UPS with more than one machine
|
||||
|
||||
#
|
||||
# Remaining items are for ShareUPS (APC expansion card) ONLY
|
||||
#
|
||||
|
||||
# UPSCLASS [ standalone | shareslave | sharemaster ]
|
||||
# Normally standalone unless you share an UPS using an APC ShareUPS
|
||||
# card.
|
||||
UPSCLASS standalone
|
||||
|
||||
# UPSMODE [ disable | share ]
|
||||
# Normally disable unless you share an UPS using an APC ShareUPS card.
|
||||
UPSMODE disable
|
||||
|
||||
#
|
||||
# ===== Configuration statements to control apcupsd system logging ========
|
||||
#
|
||||
|
||||
# Time interval in seconds between writing the STATUS file; 0 disables
|
||||
STATTIME 0
|
||||
|
||||
# Location of STATUS file (written to only if STATTIME is non-zero)
|
||||
STATFILE /var/log/apcupsd.status
|
||||
|
||||
# LOGSTATS [ on | off ] on enables, off disables
|
||||
# Note! This generates a lot of output, so if
|
||||
# you turn this on, be sure that the
|
||||
# file defined in syslog.conf for LOG_NOTICE is a named pipe.
|
||||
# You probably do not want this on.
|
||||
LOGSTATS off
|
||||
|
||||
# Time interval in seconds between writing the DATA records to
|
||||
# the log file. 0 disables.
|
||||
DATATIME 0
|
||||
|
||||
# Battery date - 8 characters
|
||||
BATTDATE {{ apcupsd_battery_date }}
|
6
roles/apcupsd/templates/apcupsd.j2
Normal file
6
roles/apcupsd/templates/apcupsd.j2
Normal file
|
@ -0,0 +1,6 @@
|
|||
# {{ ansible_managed }}
|
||||
# Defaults for apcupsd initscript
|
||||
|
||||
# Apcupsd-devel internal configuration
|
||||
APCACCESS=/sbin/apcaccess
|
||||
ISCONFIGURED=yes
|
2
roles/apcupsd/vars/main.yml
Normal file
2
roles/apcupsd/vars/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
apcupsd_battery_date: "02/13/15"
|
|
@ -5,6 +5,7 @@
|
|||
roles:
|
||||
- base
|
||||
- sshkeys
|
||||
- apcupsd
|
||||
- golang
|
||||
- grafana
|
||||
- nginx
|
||||
|
|
Loading…
Reference in a new issue