I am setting up a Netgate 6100. Just saw this module published last week! I was attempting to setup the statics in my host_vars file, but I keep getting an IndexError when I try and loop. If I set the vars statically like name: "{{ host_dhcp.statics.name }}" it will work, but no loops will.
failed: [netgate6100] (item={'name': 'example1', 'macaddr': 'xx:xx:xx:xx:xx:xx', 'ipaddr': '10.XX.XX.XX', 'state': 'present'}) => changed=false
ansible_loop_var: item
item:
ipaddr: 10.XX.XX.XX
macaddr: xx:xx:xx:xx:xx:xx
name: example1
state: present
module_stderr: |-
Shared connection to 10.XX.XX.1 closed.
module_stdout: |-
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1674504929.533209-47389-111350374029904/AnsiballZ_pfsense_dhcp_static.py", line 107, in <module>
_ansiballz_main()
File "/root/.ansible/tmp/ansible-tmp-1674504929.533209-47389-111350374029904/AnsiballZ_pfsense_dhcp_static.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/root/.ansible/tmp/ansible-tmp-1674504929.533209-47389-111350374029904/AnsiballZ_pfsense_dhcp_static.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.pfsensible.core.plugins.modules.pfsense_dhcp_static', init_globals=dict(_module_fqn='ansible_collections.pfsensible.core.plugins.modules.pfsense_dhcp_static', _modlib_path=modlib_path),
File "/usr/local/lib/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/local/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/ansible_pfsensible.core.pfsense_dhcp_static_payload_bjgy4rbm/ansible_pfsensible.core.pfsense_dhcp_static_payload.zip/ansible_collections/pfsensible/core/plugins/modules/pfsense_dhcp_static.py", line 362, in <module>
File "/tmp/ansible_pfsensible.core.pfsense_dhcp_static_payload_bjgy4rbm/ansible_pfsensible.core.pfsense_dhcp_static_payload.zip/ansible_collections/pfsensible/core/plugins/modules/pfsense_dhcp_static.py", line 357, in main
File "/tmp/ansible_pfsensible.core.pfsense_dhcp_static_payload_bjgy4rbm/ansible_pfsensible.core.pfsense_dhcp_static_payload.zip/ansible_collections/pfsensible/core/plugins/module_utils/module_base.py", line 232, in run
File "/tmp/ansible_pfsensible.core.pfsense_dhcp_static_payload_bjgy4rbm/ansible_pfsensible.core.pfsense_dhcp_static_payload.zip/ansible_collections/pfsensible/core/plugins/module_utils/module_base.py", line 169, in _add
File "/tmp/ansible_pfsensible.core.pfsense_dhcp_static_payload_bjgy4rbm/ansible_pfsensible.core.pfsense_dhcp_static_payload.zip/ansible_collections/pfsensible/core/plugins/modules/pfsense_dhcp_static.py", line 296, in _copy_and_add_target
File "/tmp/ansible_pfsensible.core.pfsense_dhcp_static_payload_bjgy4rbm/ansible_pfsensible.core.pfsense_dhcp_static_payload.zip/ansible_collections/pfsensible/core/plugins/modules/pfsense_dhcp_static.py", line 284, in _find_last_dhcp_static_index
IndexError: list index out of range
Well, that's what I get for just taking someone's module as is ;). I have an initial fix in #52 if you'd like to test that out. I want to add some more tests and checks though.
I am setting up a Netgate 6100. Just saw this module published last week! I was attempting to setup the statics in my
host_vars
file, but I keep getting an IndexError when I try and loop. If I set the vars statically likename: "{{ host_dhcp.statics.name }}"
it will work, but no loops will.My
host_vars
The task:
The error: