ansible/roles/nut/tasks/upsd.yml

65 lines
1.5 KiB
YAML
Raw Normal View History

2023-01-25 10:53:02 +01:00
---
2023-01-25 15:55:20 +01:00
- name: install server for Debian / Ubuntu
apt:
name:
- nut-server
when: ansible_distribution in ["Debian", "Ubuntu"]
2023-04-10 21:25:17 +02:00
- name: "set MAXAGE to 25 in /etc/nut/upsd.conf"
lineinfile:
dest: /etc/nut/upsd.conf
regexp: '^#\s*MAXAGE.*$'
line: 'MAXAGE 25'
2023-01-25 10:53:02 +01:00
- name: add UPS device(s) config to /etc/nut/ups.conf
blockinfile:
path: /etc/nut/ups.conf
block: |
[{{ nut_device.name }}]
2023-04-10 21:25:17 +02:00
{% for key, value in nut_device.config.items() %} {{ key }} = {{ value | to_json }}
2023-01-25 10:53:02 +01:00
{% endfor %}
- name: set up NUT user(s) to /etc/nut/upsd.users
blockinfile:
path: /etc/nut/upsd.users
block: |
[admin]
password = "{{ nut_admin_password }}"
actions = SET
instcmds = ALL
[upsmon]
password = "{{ nut_upsmon_password }}"
upsmon {{ nut_types[nut_mode] }}
2023-01-25 18:15:16 +01:00
- name: allow NUT to listen to all IPs
blockinfile:
2023-01-25 17:55:51 +01:00
path: /etc/nut/upsd.conf
2023-01-25 18:15:16 +01:00
block: |
LISTEN 0.0.0.0
LISTEN ::1
when: nut_mode == "netserver"
2023-01-25 17:55:51 +01:00
2023-01-25 10:53:02 +01:00
- name: start and enable nut-upsd
service:
name: nut-upsd
runlevel: default
state: started
enabled: true
when: ansible_distribution == "Alpine"
2023-01-25 17:01:36 +01:00
- name: start and enable nut-server
systemd:
name: nut-server
state: started
enabled: true
when: ansible_distribution in ["Debian", "Ubuntu"]
- name: start and enable nut-driver-enumerator
systemd:
name: nut-driver-enumerator
state: started
enabled: true
when: ansible_distribution == "Archlinux"