Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError when moving a firewall policy in check mode #236

Open
jplitza opened this issue Mar 1, 2023 · 1 comment
Open

ValueError when moving a firewall policy in check mode #236

jplitza opened this issue Mar 1, 2023 · 1 comment

Comments

@jplitza
Copy link

jplitza commented Mar 1, 2023

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:

def fortios_firewall(data, fos, check_mode):
fos.do_member_operation("firewall", "policy")
if data["action"] == "move":
resp = move_fortios_firewall(data, fos)
elif data["firewall_policy"]:
resp = firewall_policy(data, fos, check_mode)
else:
fos._module.fail_json(msg="missing task body: %s" % ("firewall_policy"))
if check_mode:
return resp
return (
not is_successful_status(resp),
is_successful_status(resp)
and (resp["revision_changed"] if "revision_changed" in resp else True),
resp,
{},
)

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants