Trying to gather L3 subinterfaces fails in initial_handling()
Closed this issue ยท 4 comments
Describe the bug
Trying to gather L3 subinterfaces fails
Expected behavior
L3 Subinterfaces should be able to be gathered and registered.
Current behavior
The below task:
- name: Gather L3 sub interfaces
paloaltonetworks.panos.panos_l3_subinterface:
provider: "{{ device }}"
template: "{{ template | default(omit) }}"
gathered_filter: "name contains 'ethernet'"
state: gathered
register: l3_subinterfaces
Fails with the below error:
The full traceback is:
Traceback (most recent call last):
File "/Users/fahad/.ansible/tmp/ansible-tmp-1695668172.465157-81797-35254441892918/AnsiballZ_panos_l3_subinterface.py", line 107, in <module>
_ansiballz_main()
File "/Users/fahad/.ansible/tmp/ansible-tmp-1695668172.465157-81797-35254441892918/AnsiballZ_panos_l3_subinterface.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/Users/fahad/.ansible/tmp/ansible-tmp-1695668172.465157-81797-35254441892918/AnsiballZ_panos_l3_subinterface.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.paloaltonetworks.panos.plugins.modules.panos_l3_subinterface', init_globals=dict(_module_fqn='ansible_collections.paloaltonetworks.panos.plugins.modules.panos_l3_subinterface', _modlib_path=modlib_path),
File "<frozen runpy>", line 226, in run_module
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "/var/folders/_7/qdln6qcx5z15jbkl489s_cpm0000gp/T/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload_oqooq9bt/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_l3_subinterface.py", line 230, in <module>
File "/var/folders/_7/qdln6qcx5z15jbkl489s_cpm0000gp/T/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload_oqooq9bt/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_l3_subinterface.py", line 226, in main
File "/var/folders/_7/qdln6qcx5z15jbkl489s_cpm0000gp/T/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload_oqooq9bt/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/module_utils/panos.py", line 425, in process
File "/var/folders/_7/qdln6qcx5z15jbkl489s_cpm0000gp/T/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload_oqooq9bt/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_l3_subinterface.py", line 154, in initial_handling
TypeError: argument of type 'NoneType' is not iterable
fatal: [panorama]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/Users/fahad/.ansible/tmp/ansible-tmp-1695668172.465157-81797-35254441892918/AnsiballZ_panos_l3_subinterface.py\", line 107, in <module>\n _ansiballz_main()\n File \"/Users/fahad/.ansible/tmp/ansible-tmp-1695668172.465157-81797-35254441892918/AnsiballZ_panos_l3_subinterface.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/fahad/.ansible/tmp/ansible-tmp-1695668172.465157-81797-35254441892918/AnsiballZ_panos_l3_subinterface.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.paloaltonetworks.panos.plugins.modules.panos_l3_subinterface', init_globals=dict(_module_fqn='ansible_collections.paloaltonetworks.panos.plugins.modules.panos_l3_subinterface', _modlib_path=modlib_path),\n File \"<frozen runpy>\", line 226, in run_module\n File \"<frozen runpy>\", line 98, in _run_module_code\n File \"<frozen runpy>\", line 88, in _run_code\n File \"/var/folders/_7/qdln6qcx5z15jbkl489s_cpm0000gp/T/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload_oqooq9bt/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_l3_subinterface.py\", line 230, in <module>\n File \"/var/folders/_7/qdln6qcx5z15jbkl489s_cpm0000gp/T/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload_oqooq9bt/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_l3_subinterface.py\", line 226, in main\n File \"/var/folders/_7/qdln6qcx5z15jbkl489s_cpm0000gp/T/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload_oqooq9bt/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/module_utils/panos.py\", line 425, in process\n File \"/var/folders/_7/qdln6qcx5z15jbkl489s_cpm0000gp/T/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload_oqooq9bt/ansible_paloaltonetworks.panos.panos_l3_subinterface_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_l3_subinterface.py\", line 154, in initial_handling\nTypeError: argument of type 'NoneType' is not iterable\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
Possible solution
Change line 154 in the initial_handling() function to if (module.params["name"] is None) or ("." not in module.params["name"]):
or use some similar way to check for existence of module.params["name"] before proceeding.
Steps to reproduce
- Have some L3 subinterfaces in a panorama template or on a firewall.
- Try to gather them with a task like below:
- name: Gather L3 sub interfaces
paloaltonetworks.panos.panos_l3_subinterface:
provider: "{{ device }}"
template: "{{ template | default(omit) }}"
gathered_filter: "name contains 'ethernet'"
state: gathered
register: l3_subinterfaces
Context
Trying to gather L3 interfaces for use in a file.
Your Environment
- Collection: paloaltonetworks.panos 2.17.6
- Python: Python 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
- Ansible:
ansible [core 2.15.4]
config file = /Users/fahad/Code/fy-loc-awx-ansible/ansible.cfg
configured module search path = ['/Users/fahad/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/8.4.0/libexec/lib/python3.11/site-packages/ansible
ansible collection location = /Users/fahad/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/8.4.0/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
- PAN-OS Python Library & version: pan-os-python '1.11.0'
๐ Thanks for opening your first issue here! Welcome to the community!
It's easily possible to fix the initial issue within initial_handling
, but then the listing
returned is empty, so this issue goes deeper than the initial error message. Will need more investigation.
parent_handling
happens before gathered_filter
processing. But currently the parent needs to be defined to do the gathering.
๐ This issue has been resolved in version 2.20.0 ๐
The release is available on Ansible Galaxy and GitHub release
Posted by semantic-release bot