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

fixed: variable 'rsp' referenced before assignment #218

Conversation

rothman857
Copy link
Contributor

SUMMARY

The following task is not idempotent:

    community.network.avi_useraccount:
      avi_credentials: "{{ avi_credentials }}"
      old_password: "{{ avi_default_password }}"
      force_change: True
      password: "{{ avi_password }}"
      username: "{{ avi_username }}"

On the first run it completes successfully, but subsequent runs result in the following error:

line 148, in main\nUnboundLocalError: local variable 'rsp' referenced before assignment\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

community.network.avi_useraccount

ADDITIONAL INFORMATION

Run this task more than once in succession:

    community.network.avi_useraccount:
      avi_credentials: "{{ avi_credentials }}"
      old_password: "{{ avi_default_password }}"
      force_change: True
      password: "{{ avi_password }}"
      username: "{{ avi_username }}"

After a successful first run, subsequent runs will fail.

Before:

TASK [Set Admin Password] ******************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "/home/vagrant/.venv/lib64/python3.6/site-packages/urllib3/connectionpool.py:1020: InsecureRequestWarning: Unverified HTTPS request is being made to host '10.xxx.xxx.xxx'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning,\nStatus Code 401 msg {\"error\": \"Invalid credentials\"}\n/home/vagrant/.venv/lib64/python3.6/site-packages/urllib3/connectionpool.py:1020: InsecureRequestWarning: Unverified HTTPS request is being made to host '10.xxx.xxx.xxx'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning,\nTraceback (most recent call last):\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1613701146.246441-11203-84759223293469/AnsiballZ_avi_useraccount.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1613701146.246441-11203-84759223293469/AnsiballZ_avi_useraccount.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1613701146.246441-11203-84759223293469/AnsiballZ_avi_useraccount.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.network.plugins.modules.avi_useraccount', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.network.avi_useraccount_payload_tjd3xypl/ansible_community.network.avi_useraccount_payload.zip/ansible_collections/community/network/plugins/modules/avi_useraccount.py\", line 152, in <module>\n  File \"/tmp/ansible_community.network.avi_useraccount_payload_tjd3xypl/ansible_community.network.avi_useraccount_payload.zip/ansible_collections/community/network/plugins/modules/avi_useraccount.py\", line 148, in main\nUnboundLocalError: local variable 'rsp' referenced before assignment\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

After:

TASK [Set Admin Password] ******************************************************************************************************************
ok: [localhost]

@ansibullbot
Copy link
Collaborator

@ansibullbot
Copy link
Collaborator

@rothman857, just so you are aware we have a dedicated Working Group for network.
You can find other people interested in this in #ansible-network on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibullbot ansibullbot added affects_2.10 bug This issue/PR relates to a bug community_review module module needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) python3 small_patch Hopefully easy to review stale_ci CI is older than 7 days, rerun before merging traceback labels Mar 26, 2021
@dericcrago
Copy link
Contributor

Hi @chaitanyaavi @ericsysmin @grastogi23 @khaltore, this looks like a 1 line fix for avi_useraccount, is this ok to merge?

@chaitanyaavi
Copy link

chaitanyaavi commented Apr 6, 2021 via email

@chaitanyaavi
Copy link

chaitanyaavi commented Apr 6, 2021 via email

@rothman857
Copy link
Contributor Author

rothman857 commented Apr 15, 2021

I noticed the fix was included in the new vmware.alb collection. It doesn't appear to be published to Galaxy yet, but I guess this is closable.

@ansibullbot ansibullbot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI and removed stale_ci CI is older than 7 days, rerun before merging labels Nov 10, 2021
@dericcrago dericcrago merged commit 745d91e into ansible-collections:main Dec 2, 2021
@patchback
Copy link

patchback bot commented Dec 6, 2021

Backport to stable-2: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-2/745d91e182810f32dd9f96338302cefc765673cc/pr-218

Backported as #341

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback
Copy link

patchback bot commented Dec 6, 2021

Backport to stable-1: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-1/745d91e182810f32dd9f96338302cefc765673cc/pr-218

Backported as #340

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback
Copy link

patchback bot commented Dec 6, 2021

Backport to stable-3: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-3/745d91e182810f32dd9f96338302cefc765673cc/pr-218

Backported as #342

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Dec 6, 2021
Co-authored-by: rfralick <[email protected]>
(cherry picked from commit 745d91e)
patchback bot pushed a commit that referenced this pull request Dec 6, 2021
Co-authored-by: rfralick <[email protected]>
(cherry picked from commit 745d91e)
patchback bot pushed a commit that referenced this pull request Dec 6, 2021
Co-authored-by: rfralick <[email protected]>
(cherry picked from commit 745d91e)
dericcrago pushed a commit that referenced this pull request Dec 6, 2021
Co-authored-by: rfralick <[email protected]>
(cherry picked from commit 745d91e)

Co-authored-by: rothman857 <[email protected]>
dericcrago pushed a commit that referenced this pull request Dec 6, 2021
Co-authored-by: rfralick <[email protected]>
(cherry picked from commit 745d91e)

Co-authored-by: rothman857 <[email protected]>
dericcrago pushed a commit that referenced this pull request Dec 6, 2021
Co-authored-by: rfralick <[email protected]>
(cherry picked from commit 745d91e)

Co-authored-by: rothman857 <[email protected]>
@dericcrago
Copy link
Contributor

thank you for your contribution @rothman857

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.10 bug This issue/PR relates to a bug community_review module module needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI new_contributor Help guide this first time contributor plugins plugin (any type) python3 small_patch Hopefully easy to review traceback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants