Recent versions of NUT have a *nut.target* unit that collects all of the NUT-related services. Enabling any of the services individually does effectively nothing, as it only adds the service as a `Wants` dependency for *nut.target*, and that unit already has dependencies for all of them. Thus, in order for the service to start at boot, *nut.target* has to be enabled instead. In situations where only *nut-monitor* should be enabled, enabling *nut.target* is inappropriate, since that enables *nut-driver* and *nut-server* as well. It's not clear why upstream made this change (it was part of a [HUGE pull request][0]), but restoring the desired behavior is easy enough by clearing the dependencies from *nut.target*. Services that we want to start automatically can still be enabled individually, and will start as long as *nut.target* is enabled. [0]: https://github.com/networkupstools/nut/pull/330
67 lines
1.1 KiB
YAML
67 lines
1.1 KiB
YAML
- name: ensure nut is installed
|
|
package:
|
|
name: nut
|
|
state: present
|
|
tags:
|
|
- install
|
|
|
|
- name: ensure upsd is configured
|
|
template:
|
|
src: upsd.conf.j2
|
|
dest: /etc/ups/upsd.conf
|
|
owner: root
|
|
group: nut
|
|
mode: 'o=rw,g=r,o='
|
|
notify:
|
|
- restart nut
|
|
tags:
|
|
- nut-config
|
|
- name: ensure ups is configured
|
|
template:
|
|
src: ups.conf.j2
|
|
dest: /etc/ups/ups.conf
|
|
owner: root
|
|
group: nut
|
|
mode: 'o=rw,g=r,o='
|
|
notify:
|
|
- restart nut
|
|
tags:
|
|
- nut-config
|
|
- name: ensure upsd users are configured
|
|
template:
|
|
src: upsd.users.j2
|
|
dest: /etc/ups/upsd.users
|
|
owner: root
|
|
group: nut
|
|
mode: 'o=rw,g=r,o='
|
|
notify:
|
|
- restart nut
|
|
tags:
|
|
- nut-users
|
|
|
|
- name: ensure nut starts at boot
|
|
service:
|
|
name: nut-server
|
|
enabled: true
|
|
tags:
|
|
- service
|
|
- name: ensure nut is running
|
|
service:
|
|
name: nut-server
|
|
state: started
|
|
tags:
|
|
- service
|
|
|
|
- name: ensure firewall is configured for nut
|
|
firewalld:
|
|
port: '{{ nut_listen.port }}/tcp'
|
|
state: enabled
|
|
immediate: true
|
|
permanent: true
|
|
tags:
|
|
- firewalld
|
|
|
|
- name: apply nut-common role
|
|
include_role:
|
|
name: nut-common
|