fortinet-ansible-dev / ansible-galaxy-fortios-collection

GNU General Public License v3.0
84 stars 48 forks source link

ValueError when moving a firewall policy in check mode #236

Open jplitza opened 1 year ago

jplitza commented 1 year ago

Invocation:

- fortinet.fortios.fortios_firewall_policy:
    access_token: foobar
    action: move
    self: 5
    after: 4

Leads to this error in check mode (-C):

Traceback (most recent call last):
  File "<stdin>", line 107, in <module>                                                                      
  File "<stdin>", line 99, in _ansiballz_main                                                                                                                                                                              
  File "<stdin>", line 47, in invoke_module                                                                  
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module                                                
    return _run_module_code(code, init_globals, run_name, mod_spec)                                          
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code                                           
    _run_code(code, mod_globals, init_globals,                                                               
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code                                                  
    exec(code, run_globals)                                                                                  
  File "/tmp/ansible_fortinet.fortios.fortios_firewall_policy_payload_q02j_ql7/ansible_fortinet.fortios.fortios_firewall_policy_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_firewall_policy.py", line 11647, in <module>                                                                                 
  File "/tmp/ansible_fortinet.fortios.fortios_firewall_policy_payload_q02j_ql7/ansible_fortinet.fortios.fortios_firewall_policy_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_firewall_policy.py", line 11613, in main
ValueError: too many values to unpack (expected 4)

My guess is that this code segment is to blame:

https://github.com/fortinet-ansible-dev/ansible-galaxy-fortios-collection/blob/289ee01fc3c84924fa9c4a1dd21f13fa318c2e72/plugins/modules/fortios_firewall_policy.py#L2111-L2128

Furthermore, looking at the code, I doubt that check mode is even honored (since the check_mode parameter isn't even passed to to move_fortios_firewall()) and the move is carried out anyway (but I didn't verify).

MaxxLiu22 commented 1 year ago

Hi @jplitza ,

Thank you for raising this issue, I can reproduce that, there do are some problems around check operation, I have reported it along with your previous issue to the development team.

Thanks, Maxx