You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have seen this intermittent issue for some firewalls where when we collect running jobs from firewalls by running 'show jobs all' command using panos_op module, it fails with UnicodeDecodeError. It seems some of the characters panos_op module doesn't like it. Some parsing enhancement in this panos.py script where it handles such unicode would be helpful
name: "{{ request_id }}: Collect jobs on firewall {{ ansible_host }} (show jobs all)"
vars:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
panos_op:
provider: '{{ provider }}'
cmd: 'show jobs all'
register: show_jobs_all_info
Expected behavior
it should collect all jobs from firewall and store in variable
Current behavior
Traceback (most recent call last):
File "/users/netengauto/.ansible/tmp/ansible-tmp-1723333918.359651-3106-167098343267774/AnsiballZ_panos_op.py", line 102, in
_ansiballz_main()
File "/users/netengauto/.ansible/tmp/ansible-tmp-1723333918.359651-3106-167098343267774/AnsiballZ_panos_op.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/users/netengauto/.ansible/tmp/ansible-tmp-1723333918.359651-3106-167098343267774/AnsiballZ_panos_op.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible_collections.paloaltonetworks.panos.plugins.modules.panos_op', init_globals=None, run_name='main', alter_sys=True)
File "/opt/python/3.7.3/lib64/python3.7/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/opt/python/3.7.3/lib64/python3.7/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/opt/python/3.7.3/lib64/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/ansible_panos_op_payload_if6a328e/ansible_panos_op_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_op.py", line 170, in
File "/tmp/ansible_panos_op_payload_if6a328e/ansible_panos_op_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_op.py", line 144, in main
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/panos/firewall.py", line 243, in op
cmd, vsys, xml, cmd_xml, extra_qs, retry_on_peer
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/panos/base.py", line 4031, in op
element = self.xapi.op(cmd, vsys, False, extra_qs, retry_on_peer=retry_on_peer)
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/panos/base.py", line 3862, in method
super_method(self, *args, **kwargs)
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/pan/xapi.py", line 951, in op
self.__type_op(cmd, vsys, extra_qs)
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/pan/xapi.py", line 973, in __type_op
if not self.__set_response(response):
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/pan/xapi.py", line 257, in __set_response
return self.__set_xml_response(message_body)
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/pan/xapi.py", line 305, in __set_xml_response
self.xml_document = message_body.decode(_encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaf in position 13926: invalid start byte
Possible solution
is it possible to detect this error within the moduel and re-run using utf-8 instead of throwing an error and fail. Not sure if this is the right solution but just a proposal
Run below task in playbook. Please note I have also tried running using xml command too and gives same error.
CLI version:
name: "{{ request_id }}: Collect jobs on firewall {{ ansible_host }} (show jobs all)"
vars:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
panos_op:
provider: '{{ provider }}'
cmd: 'show jobs all'
register: show_jobs_all_info
XML version:
name: "{{ request_id }}: Collect jobs on firewall {{ ansible_host }} (show jobs all)"
vars:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
panos_op:
provider: "{{ provider }}"
cmd: ""
cmd_is_xml: true
register: show_jobs_all_info
Screenshots
Context
We are using this command prior to software upgrade to make sure no other jobs are running on firewall then we perform an upgrade on firewall. Affecting our prod firewall upgrade currently.
Describe the bug
We have seen this intermittent issue for some firewalls where when we collect running jobs from firewalls by running 'show jobs all' command using panos_op module, it fails with UnicodeDecodeError. It seems some of the characters panos_op module doesn't like it. Some parsing enhancement in this panos.py script where it handles such unicode would be helpful
vars:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
panos_op:
provider: '{{ provider }}'
cmd: 'show jobs all'
register: show_jobs_all_info
Expected behavior
it should collect all jobs from firewall and store in variable
Current behavior
Traceback (most recent call last):
File "/users/netengauto/.ansible/tmp/ansible-tmp-1723333918.359651-3106-167098343267774/AnsiballZ_panos_op.py", line 102, in
_ansiballz_main()
File "/users/netengauto/.ansible/tmp/ansible-tmp-1723333918.359651-3106-167098343267774/AnsiballZ_panos_op.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/users/netengauto/.ansible/tmp/ansible-tmp-1723333918.359651-3106-167098343267774/AnsiballZ_panos_op.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible_collections.paloaltonetworks.panos.plugins.modules.panos_op', init_globals=None, run_name='main', alter_sys=True)
File "/opt/python/3.7.3/lib64/python3.7/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/opt/python/3.7.3/lib64/python3.7/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/opt/python/3.7.3/lib64/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/ansible_panos_op_payload_if6a328e/ansible_panos_op_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_op.py", line 170, in
File "/tmp/ansible_panos_op_payload_if6a328e/ansible_panos_op_payload.zip/ansible_collections/paloaltonetworks/panos/plugins/modules/panos_op.py", line 144, in main
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/panos/firewall.py", line 243, in op
cmd, vsys, xml, cmd_xml, extra_qs, retry_on_peer
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/panos/base.py", line 4031, in op
element = self.xapi.op(cmd, vsys, False, extra_qs, retry_on_peer=retry_on_peer)
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/panos/base.py", line 3862, in method
super_method(self, *args, **kwargs)
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/pan/xapi.py", line 951, in op
self.__type_op(cmd, vsys, extra_qs)
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/pan/xapi.py", line 973, in __type_op
if not self.__set_response(response):
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/pan/xapi.py", line 257, in __set_response
return self.__set_xml_response(message_body)
File "/opt/ansible/3.7.3/lib64/python3.7/site-packages/pan/xapi.py", line 305, in __set_xml_response
self.xml_document = message_body.decode(_encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaf in position 13926: invalid start byte
Possible solution
is it possible to detect this error within the moduel and re-run using utf-8 instead of throwing an error and fail. Not sure if this is the right solution but just a proposal
Steps to reproduce
Run below task in playbook. Please note I have also tried running using xml command too and gives same error.
CLI version:
vars:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
panos_op:
provider: '{{ provider }}'
cmd: 'show jobs all'
register: show_jobs_all_info
XML version:
vars:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
panos_op:
provider: "{{ provider }}"
cmd: ""
cmd_is_xml: true
register: show_jobs_all_info
Screenshots
Context
We are using this command prior to software upgrade to make sure no other jobs are running on firewall then we perform an upgrade on firewall. Affecting our prod firewall upgrade currently.
Your Environment
The text was updated successfully, but these errors were encountered: