maxhoesel.nut_netclient
maxhoesel.nut_netclient
在目标系统上安装NUT和upsmon,并配置为通过网络使用netclient模式跟随远程UPS。
需求
- 一台运行以下发行版的主机
- Ubuntu 18.04 LTS或更新版本
- Debian 9或更新版本
- 在主机上具有提升权限
角色变量
注意:有关upsmon.conf值及其用途的更多信息,请查看这里。
nut_netclient_monitors
- 需要监视的UPS系统列表
- 必须是监视条目的列表,每个条目是一个字典,包含以下值:
system
: 要监视的系统。格式:<upsname>[@<hostname>[:<port>]]
powervalue
: 该系统为主机提供的电源数量。通常为1username
: 远程监视用户的名称password
: 远程监视用户的密码type
: UPS关系的类型,可以是master
或slave
- 示例:
nut_netclient_monitors: - system: "[email protected]" powervalue: 1 username: monitor password: a-secure-password type: slave - system: "[email protected]" powervalue: 1 username: monitor password: a-different-password type: slave
- 必需:是
- 默认:
未定义
nut_netclient_notifymsg_<type>
- 为给定消息类型设置自定义通知消息
- 有效的类型可以在upsmon手册(NOTIFYMSG部分)中找到
- 示例:
nut_netclient_notifymsg_online: UPS %s 现已恢复在线 nut_netclient_notifymsg_lowbatt: UPS %s 电量低
nut_netclient_notifyflag_<type>
- 为各个事件类型设置通知标志
- 有效的类型和标志可以在upsmon手册中找到
- 示例:
nut_netclient_notifyflag_online: SYSLOG nut_netclient_notifymsg_lowbatt: SYSLOG+WALL+EXEC
以下所有变量的前缀:nut_netclient_
名称 | 概要 | 必需 | 默认 |
---|---|---|---|
deadtime |
UPS被声明为“死亡”的时间(以秒为单位) | 15 | |
finaldelay |
最终关闭警告与命令之间的时间(秒) | 5 | |
hostsync |
主机和从机在关闭情况下的超时(秒) | 15 | |
minsupplies |
维持运行所需的最小电源数量 | 1 | |
nocommwarntime |
通信错误警告之间的间隔(秒) | 300 | |
notifycmd |
调用此命令以发送消息 | 未定义 |
|
pollfreq |
UPS轮询之间的时间(秒) | 5 | |
pollfreqalert |
在电池供电时UPS轮询之间的时间(秒) | 5 | |
powerdownflag |
upsmon在关闭期间创建的标志文件 | /etc/killpower |
|
rbwarntime |
发送电池更换消息的间隔(秒) | 43200 | |
run_as_user |
以不同用户身份运行监视器 | 未定义 |
|
shutdowncmd |
关闭系统时要运行的命令。如果包含空格,必须用引号括起来 | "/sbin/shutdown -h +0" |
|
certpath |
证书文件或数据库的路径 | 未定义 |
|
certident |
要检索的证书标识(如果使用NSS) | 未定义 |
|
certhost |
主机指令(如果使用NSS) | 未定义 |
|
certverify |
是否验证SSL证书。必须为0或1 | 未定义 |
|
forcessl |
是否强制SSL连接。必须为0或1 | 未定义 |
示例剧本
- hosts: all
become: yes
tasks:
- name: 运行 nut_netclient
include_role:
name: maxhoesel.nut_netclient
vars:
nut_netclient_monitors:
- system: "[email protected]"
powervalue: 1
username: monitor
password: a-secure-password
type: slave
测试
该角色使用tox和molecule进行测试。您需要在系统上安装以下内容:
- python3-tox
- Docker
然后,只需在该角色的根目录中运行test.sh
。您可以使用tox -l
查看并运行单个测试。
安装
ansible-galaxy install maxhoesel.nut_netclient
许可证
gpl-3.0
下载
11.9k
拥有者
Junior Automation and Infrastructure Engineer, Bachelor in CompSci. I write Ansible content and DevOps-related tools, mostly in Rust