PaloAltoNetworks/pan-os-ansible

NameError: name 'pandevice' is not defined

narasims opened this issue · 3 comments

Describe the bug

Finding the address object failure while using the paloaltonetworks.panos.panos_object module.

Expected behavior

supposed to find the object

Current behavior

TASK [Gather PanOS object facts] ******************************************************************************************************************************************************************************************************
task path: /home/narasims/NET/playbooks/Palo-test.yml:51
The full traceback is:
Traceback (most recent call last):
File "/tmp/narasims/.ansible/ansible-tmp-1689714096.450628-20935-146788495293543/AnsiballZ_panos_object.py", line 107, in
_ansiballz_main()
File "/tmp/narasims/.ansible/ansible-tmp-1689714096.450628-20935-146788495293543/AnsiballZ_panos_object.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/tmp/narasims/.ansible/ansible-tmp-1689714096.450628-20935-146788495293543/AnsiballZ_panos_object.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.paloaltonetworks.panos.plugins.modules.panos_object', init_globals=dict(_module_fqn='ansible_collections.paloaltonetworks.panos.plugins.modules.panos_object', _modlib_path=modlib_path),
File "/opt/rh/rh-python38/root/lib64/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/opt/rh/rh-python38/root/lib64/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/opt/rh/rh-python38/root/lib64/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/ansible_paloaltonetworks.panos.panos_object_payload_v70_a0c0/ansible_paloaltonetworks.panos.panos_object_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_object.py", line 647, in
File "/tmp/ansible_paloaltonetworks.panos.panos_object_payload_v70_a0c0/ansible_paloaltonetworks.panos.panos_object_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_object.py", line 544, in main
File "/tmp/ansible_paloaltonetworks.panos.panos_object_payload_v70_a0c0/ansible_paloaltonetworks.panos.panos_object_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_object.py", line 297, in find_object
NameError: name 'pandevice' is not defined
fatal: [ancedaws01 -> localhost]: FAILED! => {
"changed": false,
"rc": 1
}

MSG:

MODULE FAILURE
See stdout/stderr for the exact error

MODULE_STDERR:

Traceback (most recent call last):
File "/tmp/narasims/.ansible/ansible-tmp-1689714096.450628-20935-146788495293543/AnsiballZ_panos_object.py", line 107, in
_ansiballz_main()
File "/tmp/narasims/.ansible/ansible-tmp-1689714096.450628-20935-146788495293543/AnsiballZ_panos_object.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/tmp/narasims/.ansible/ansible-tmp-1689714096.450628-20935-146788495293543/AnsiballZ_panos_object.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.paloaltonetworks.panos.plugins.modules.panos_object', init_globals=dict(_module_fqn='ansible_collections.paloaltonetworks.panos.plugins.modules.panos_object', _modlib_path=modlib_path),
File "/opt/rh/rh-python38/root/lib64/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/opt/rh/rh-python38/root/lib64/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/opt/rh/rh-python38/root/lib64/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/ansible_paloaltonetworks.panos.panos_object_payload_v70_a0c0/ansible_paloaltonetworks.panos.panos_object_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_object.py", line 647, in
File "/tmp/ansible_paloaltonetworks.panos.panos_object_payload_v70_a0c0/ansible_paloaltonetworks.panos.panos_object_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_object.py", line 544, in main
File "/tmp/ansible_paloaltonetworks.panos.panos_object_payload_v70_a0c0/ansible_paloaltonetworks.panos.panos_object_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_object.py", line 297, in find_object
NameError: name 'pandevice' is not defined

PLAY RECAP ****************************************************************************************************************************************************************************************************************************
ancedaws01 : ok=2 changed=1 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

Steps to reproduce

  • name: Filter object with IP and find associated address groups and rules
    hosts: all
    gather_facts: false

    tasks:

    • name: Gather PanOS object facts
      paloaltonetworks.panos.panos_object:
      ip_address: '10.20.20.25'
      username: 'admin'
      password: 'xyedts1536!'
      addressobject: 'ancedaws01'
      operation: 'find'
      register: object_facts
      delegate_to: localhost

Context

How has this issue affected you? What are you trying to accomplish?
Unable to find the address object to find the rules and address groups that the address object part of.

Your Environment

  • Collection: paloaltonetworks.panos
  • Python: 3.8.14
  • Ansible: core 2.13.8
  • PAN-OS Python Library & version :
    pan-os-python==1.11.0
    pan-python==0.17.0
    pandevice==0.14.0
    xmltodict==0.13.0

🎉 Thanks for opening your first issue here! Welcome to the community!

updated the following. But still facing the same issue:
paloaltonetworks.panos 2.17.3
pan-python==0.22.0
pandevice==0.14.0

Hi @narasims, I'm unclear on the eventual goal here, but the panos_object module has been deprecated now. If you want to find address objects, you can use the panos_address_object module with state: gathered. For example:

  tasks:
    - name: Gather config
      paloaltonetworks.panos.panos_address_object:
        provider: '{{ device }}'
        state: 'gathered'
        name: 'ancedaws01'
      register: result

    - name: Output
      ansible.builtin.debug:
        msg: "{{ result }}"

Screenshot 2023-09-27 at 12 37 30

There are more docs/examples using gathered here and here

If problems persist, please reopen this issue