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

global name 'module_name' is not defined #12495

Closed
adolgert opened this issue Sep 23, 2015 · 2 comments
Closed

global name 'module_name' is not defined #12495

adolgert opened this issue Sep 23, 2015 · 2 comments

Comments

@adolgert
Copy link

The script used the async keyword on a module that doesn't support async. The error message refers to an undefined variable. In the latest checkout, it's in lib/ansible/executor/task_executor.py, line 530.

if self._task.async != 0:
raise AnsibleError("async mode is not supported with the %s module" % module_name)

That "module_name" isn't in scope.

Happy Coding,
Drew

@bcoca
Copy link
Member

bcoca commented Sep 23, 2015

does this fix it for you?

diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py
index afe9605..e45b757 100644
--- a/lib/ansible/executor/task_executor.py
+++ b/lib/ansible/executor/task_executor.py
@@ -517,7 +517,7 @@ class TaskExecutor:

         if self._task.action in self._shared_loader_obj.action_loader:
             if self._task.async != 0:
-                raise AnsibleError("async mode is not supported with the %s module" % module_name)
+                raise AnsibleError("async mode is not supported with the %s module" % self._task.action)
             handler_name = self._task.action
         elif self._task.async == 0:
             handler_name = 'normal'

@adolgert
Copy link
Author

Yes! I went through to reintroduce the error, and it produces the correct error message now.
+1 for alacrity. Thanks!

bcoca added a commit that referenced this issue Sep 23, 2015
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants