Skip to content

pfsense_dhcp_server: mac_allow / mac_deny never converge (list is compared against the joined string) #262

Description

@wpfleger96

Describe the bug

mac_allow and mac_deny are declared as type='list', but the comparison against the live config uses the raw list, so any non-empty value reports changed on every run. The code that was meant to join the list is a no-op.

plugins/module_utils/dhcp_server.py (0.7.1):

# Forced options
for option in ['failover_peerip', ..., 'mac_allow', 'mac_deny', ...]:
    self._get_ansible_param(obj, option, force=True)      # obj['mac_deny'] = the *list*

for option in ['mac_allow', 'mac_deny']:
    if params[option] is None:
        params[option] = ""
    self._get_ansible_param(obj, ','.join(params[option]))   # <- passes the joined string as the *param name*

The second loop calls _get_ansible_param(obj, 'aa:bb:...,cc:dd:...'), which looks up a param with that name, finds nothing, and does nothing. obj['mac_deny'] stays a Python list; pfSense stores <mac_deny>aa:bb:cc:dd:ee:ff,11:22:33:44:55:66</mac_deny> as a comma-separated string, so the diff never matches.

Expected behavior

Declaring the same list that is already on the box is idempotent (changed=false).

Playbook

- name: IoT DHCP server
  pfsensible.core.pfsense_dhcp_server:
    interface: opt4
    enable: true
    range_from: 192.168.12.100
    range_to: 192.168.12.200
    mac_deny:
      - e8:9f:6d:8e:75:5d
      - d8:bc:38:86:20:69

Run twice: both runs report changed, and --diff shows the list on one side and the joined string on the other.

Suggested fix

Drop mac_allow/mac_deny from the forced-options loop and make the second loop assign the joined string directly:

for option in ['mac_allow', 'mac_deny']:
    obj[option] = ','.join(params[option] or [])

Workaround: omit both parameters (the module then writes an empty string, which clears any live deny/allow list).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions