ntd / ansible-role-nut

Ansible role to install and configure Nework UPS tools on Debian
MIT License
11 stars 16 forks source link

modern systemd enumerators and services per driver #14

Open pavlozt opened 10 months ago

pavlozt commented 10 months ago

In modern versions of systemd it is necessary correctly process service names

Error

for example, if Idefine single UPS named "apc"

    nut_ups:
      - name: apc
         ...

got error :

RUNNING HANDLER [ntd.nut : restart nut] **********************************************************************************************************************************
failed: (item=nut-driver) => {"ansible_loop_var": "item", "changed": false, "item": "nut-driver", "msg": "Could not find the requested service nut-driver: host"}

because there are no "nut-driver" service in debian 12, but created named "nut-driver@apc" service.

Workaround

Define additional variable :

    nut_services:        # Name of the services to enable
      - nut-driver@apc
      - nut-monitor
      - nut-server
pavlozt commented 10 months ago

Ansible does not yet support globs in the systemd module. It is unknown when support for Systemd enumerator will appear, so I suggest slightly modifying examples in the Readme for now:

nut_services:
  - nut-driver@apc
  - nut-monitor
  - nut-server

оr even use systemd target like :

nut_services:
  - nut-driver.target
  - nut-monitor
  - nut-server