ntd / ansible-role-nut

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

nut_ups_extra Incorrect Location #7

Closed jdohnstad closed 3 years ago

jdohnstad commented 3 years ago

At least with my version of NUT it seems like the "nut_ups_extra" placed after the ups definitions results in failure to load. Here is a simple play:

---
- name: Nut Play
  hosts: all
  become: yes
  tasks:
    - name: Nut
      include_role:
        name: ntd.nut
      vars:
        nut_ups:
          - name: smt1500rm2u
            driver: usbhid-ups
            device: auto
            description: smt1500rm2u

This produces ups.conf:

# Ansible managed

[smt1500rm2u]
    driver = usbhid-ups
    port   = auto
    desc   = "smt1500rm2u"

maxretry = 3

This will fail to be loaded, however:

> upsdrvctl start
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33

Fatal error: 'maxretry' is not a valid variable name for this driver.

Look in the man page or call this driver with -h for a list of
valid variable names and flags.

By simply moving this directive up higher in the file, it is then correct:

# Ansible managed

maxretry = 3
[smt1500rm2u]
    driver = usbhid-ups
    port   = auto
    desc   = "smt1500rm2u"

So, at least with my version, it appears that global options such as this need to come before any ups sections otherwise it gets confused and thinks they are part of the UPS config.

ntd commented 3 years ago

Good catch: after seeing it, it seems quite obvious the order is wrong.

I just pushed a fix in the dev branch: could you test it, please?

jdohnstad commented 3 years ago

Yep, looks to fix the issue.