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

ansible-playbook --check fails with error #32

Closed
GuyFoetz opened this issue May 3, 2021 · 4 comments · May be fixed by #33
Closed

ansible-playbook --check fails with error #32

GuyFoetz opened this issue May 3, 2021 · 4 comments · May be fixed by #33

Comments

@GuyFoetz
Copy link

GuyFoetz commented May 3, 2021

SUMMARY

When executing a playbook with --check a Task with a command will fail due to a variable not being assigned.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

os6_config

ANSIBLE VERSION
ansible 2.10.5
  python version = 3.8.6 (default, Jan 27 2021, 15:42:20) [GCC 10.2.0]

CONFIGURATION
ANSIBLE_SSH_ARGS(ansible.cfg) = -o ForwardAgent=yes
DEFAULT_HOST_LIST(ansible.cfg) = ['inventory.yaml']
HOST_KEY_CHECKING(ansible.cfg) = False
INTERPRETER_PYTHON(ansible.cfg) = auto
OS / ENVIRONMENT

Ubuntu 20.10

STEPS TO REPRODUCE

While running a vlan configuration on os6 with --check to see if the command is executed correctly you get the error

ansible-playbook playbook.yaml  --tags vlan --check -vvv

hostvar:

os6_interface:
    Gi1/0/1:
      portmode: access
      admin: up
EXPECTED RESULTS
ACTUAL RESULTS
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: UnboundLocalError: local variable 'result_banners' referenced before assignment
fatal: [cnc-e114-r01-sw2]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):
  File \".ansible/tmp/ansible-local-18941ek58ufs3/ansible-tmp-1620024310.6947634-18949-276975040182545/AnsiballZ_os6_config.py\", line 102, in <module>
    _ansiballz_main()
  File \".ansible/tmp/ansible-local-18941ek58ufs3/ansible-tmp-1620024310.6947634-18949-276975040182545/AnsiballZ_os6_config.py\", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \".ansible/tmp/ansible-local-18941ek58ufs3/ansible-tmp-1620024310.6947634-18949-276975040182545/AnsiballZ_os6_config.py\", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.dellemc.os6.plugins.modules.os6_config', init_globals=None, run_name='__main__', alter_sys=True)
  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_dellemc.os6.os6_config_payload_70h1wnsr/ansible_dellemc.os6.os6_config_payload.zip/ansible_collections/dellemc/os6/plugins/modules/os6_config.py\", line 410, in <module>
  File \"/tmp/ansible_dellemc.os6.os6_config_payload_70h1wnsr/ansible_dellemc.os6.os6_config_payload.zip/ansible_collections/dellemc/os6/plugins/modules/os6_config.py\", line 390, in main
UnboundLocalError: local variable 'result_banners' referenced before assignment
", "module_stdout": "", "msg": "MODULE FAILURE
See stdout/stderr for the exact error", "rc": 1}
@GuyFoetz
Copy link
Author

GuyFoetz commented May 3, 2021

pull request with the fix will fallow soon :)

@ewenmcneill
Copy link

I ran into this same issue with dellemc.os6.os6_config on Ansible 2.10 on CentOS 7, and can confirm that the fix in PR #33 does allow running to completion in check mode for me too. (The problem appears to be that result_banners is only generated in non-check mode, but it is included in the returned result unconditionally; setting result_banners to an empty array works around this non-initialisation in check mode.)

Please merge #33 or an equivalent fix; it looks like a reasonable fix to me, and without it neither update: check nor ansible-playbook .... -C work AFAICT.

Ewen

@timway
Copy link

timway commented Jul 22, 2022

Just encountered this issue in os6_config (check mode) as well after installing the most recent collection via ansible-galaxy. The environment is the Ansible Automation Platform 2.2 ee-supported-rhel8 image with the collection installed.

@elpuma1969

@mryan
Copy link

mryan commented Aug 24, 2022

I have also ran into this issue. Being the core config module, most of the roles depend on this one and not having a check mode is a significant deterrent to using the whole collection.

lagrip added a commit to scsitteam/dellemc.os6 that referenced this issue Jan 12, 2023
assign default value for result_banners fixing issue ansible-collections#32
@GuyFoetz GuyFoetz closed this as completed Mar 6, 2024
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

Successfully merging a pull request may close this issue.

4 participants