Repository: ansible/ansible

Issue:
'TaskQueueManager' object has no attribute 'callback_obj'
<!---
Verify first that your issue/request is not already reported on GitHub.
THIS FORM WILL BE READ BY A MACHINE, COMPLETE ALL SECTIONS AS DESCRIBED.
Also test if the latest release, and devel branch are affected too.
ALWAYS add information AFTER (OUTSIDE) these html comments.
Otherwise it may end up being automatically closed by our bot. -->

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
<!--- Insert, BELOW THIS COMMENT, the name of the module, plugin, task or feature.
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the full path-->

##### ANSIBLE VERSION
<!--- Paste, BELOW THIS COMMENT, verbatim output from "ansible --version" between quotes below -->
```
2.5.3
```

##### CONFIGURATION
<!--- If using Ansible 2.4 or above, paste, BELOW THIS COMMENT, the results of "ansible-config dump --only-changed"
Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).-->

##### OS / ENVIRONMENT
<!--- Mention, BELOW THIS COMMENT, the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.-->
Debian GNU/Linux 9.4 (stretch)
Ansible 2.5.3-1ppa~xenial

##### SUMMARY
<!--- Explain the problem briefly -->
When I run my usual playbook with ansible 2.5.3, I got the following error message and ansible stop

` 'TaskQueueManager' object has no attribute 'callback_obj' `
This issue happened after I updated my system and got an Ansible update. If I restore the previous version (2.4.2), I have no error.


##### STEPS TO REPRODUCE
<!--- For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used. -->

I don't have a clear steps to reproduce the issue yet.

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

The playbook runs

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
ERROR! Unexpected Exception, this is probably a bug: 'TaskQueueManager' object has no attribute 'callback_obj'
to see the full traceback, use -vvv
```

I did not have a chance to run the same command in "-vvv". The issue happens on a production server and I downgraded as soon as I can. But I'll try to reproduce it on a different system and run -vvv





Discussion:
Looking at the installed code on ansible 2.5.3 on my Debian system (/usr/lib/python2.7/dist-packages/ansible), I might have found something suspicious.

In the _executor/task_queue_manager.py_ file, there is this code:
```python
            callback_obj = callback_plugin()
            try:
                callback_obj.set_options()
            except AttributeError:
                    display.deprecated("%s callback, does not support setting 'options', it will work for now, "
                                       " but this will be required in the future and should be updated, "
                                       " see the 2.4 porting guide for details." % self.callback_obj._load_name, version="2.9")
            self._callback_plugins.append(callback_obj)
```

The use of **self.callback_obj** does not seem right since the object define this variable. But in this function, there is a local variable named _callback_obj_ define. And nowhere else in the code there is a such variable name (grep -R '.callback_obj').

So I suspect the fix to be:
```diff
-                                       " see the 2.4 porting guide for details." % self.callback_obj._load_name, version="2.9")
+                                       " see the 2.4 porting guide for details." % callback_obj._load_name, version="2.9")
```



Resolving patch:
diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py
--- a/lib/ansible/executor/task_queue_manager.py
+++ b/lib/ansible/executor/task_queue_manager.py
@@ -210,7 +210,7 @@ def load_callbacks(self):
             except AttributeError:
                     display.deprecated("%s callback, does not support setting 'options', it will work for now, "
                                        " but this will be required in the future and should be updated, "
-                                       " see the 2.4 porting guide for details." % self.callback_obj._load_name, version="2.9")
+                                       " see the 2.4 porting guide for details." % callback_obj._load_name, version="2.9")
             self._callback_plugins.append(callback_obj)
 
         self._callbacks_loaded = True


Test patch: