ansible/roles/nut/tasks/upsd.yml

51 lines
1.2 KiB
YAML

---
- name: install server for Debian / Ubuntu
apt:
name:
- nut-server
when: ansible_distribution in ["Debian", "Ubuntu"]
- 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 }}"
{% 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] }}
- name: start and enable nut-upsd
service:
name: nut-upsd
runlevel: default
state: started
enabled: true
when: ansible_distribution == "Alpine"
- 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"