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).
Describe the bug
mac_allowandmac_denyare declared astype='list', but the comparison against the live config uses the raw list, so any non-empty value reportschangedon every run. The code that was meant to join the list is a no-op.plugins/module_utils/dhcp_server.py(0.7.1):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
Run twice: both runs report
changed, and--diffshows the list on one side and the joined string on the other.Suggested fix
Drop
mac_allow/mac_denyfrom the forced-options loop and make the second loop assign the joined string directly:Workaround: omit both parameters (the module then writes an empty string, which clears any live deny/allow list).