65 lines
1.5 KiB
YAML
65 lines
1.5 KiB
YAML
---
|
|
|
|
- name: install server for Debian / Ubuntu
|
|
apt:
|
|
name:
|
|
- nut-server
|
|
when: ansible_distribution in ["Debian", "Ubuntu"]
|
|
|
|
- name: "set MAXAGE to 25 in /etc/nut/upsd.conf"
|
|
lineinfile:
|
|
dest: /etc/nut/upsd.conf
|
|
regexp: '^#\s*MAXAGE.*$'
|
|
line: 'MAXAGE 25'
|
|
|
|
- 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 | to_json }}
|
|
{% 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: allow NUT to listen to all IPs
|
|
blockinfile:
|
|
path: /etc/nut/upsd.conf
|
|
block: |
|
|
LISTEN 0.0.0.0
|
|
LISTEN ::1
|
|
when: nut_mode == "netserver"
|
|
|
|
- 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"
|