Repository: ansible/ansible

Issue:
Hipchat Callback not working
##### ISSUE TYPE
- Bug Report
##### ANSIBLE VERSION

```
ansible 2.1.0.0
  config file = /root/ansible/ansible.cfg
  configured module search path = ['modules']
```
##### CONFIGURATION

```
[defaults]
library = modules
log_path = /tmp/ansible.log
roles_path = roles
callback_plugins = callbacks/
deprecation_warnings=False
callback_whitelist = hipchat
```
##### OS / ENVIRONMENT

CentOS7
##### SUMMARY

Hipchat Callback: https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/callback/hipchat.py 
is not working. 
Vars can not be set.
##### STEPS TO REPRODUCE

Enable hipchat callback via ansible.cfg whitelisting.
Configure the required Hipchat ENV-Vars.
Run any playbook, following error occurs:

```
PLAY [Staging Packages] ********************************************************
 [WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin (</usr/lib/python2.7/site-packages/ansible/plugins/callback/hipchat.CallbackModule object at 0x31c4750>):
'Play' object has no attribute 'playbook'
 [WARNING]: Failure using method (v2_playbook_on_stats) in callback plugin (</usr/lib/python2.7/site-packages/ansible/plugins/callback/hipchat.CallbackModule object at 0x2c4c750>):
'CallbackModule' object has no attribute 'display'
```
##### EXPECTED RESULTS

Message send to hipchat room.
##### ACTUAL RESULTS

Hipchat message not working
##### MISC

The display error can be solved by changing the callback from:
self.display.warning('
to
self._display.warning('



Discussion:

Resolving patch:
diff --git a/lib/ansible/plugins/callback/hipchat.py b/lib/ansible/plugins/callback/hipchat.py
--- a/lib/ansible/plugins/callback/hipchat.py
+++ b/lib/ansible/plugins/callback/hipchat.py
@@ -31,6 +31,7 @@
 from ansible.plugins.callback import CallbackBase
 from ansible.module_utils.urls import open_url
 
+
 class CallbackModule(CallbackBase):
     """This is an example ansible callback plugin that sends status
     updates to a HipChat channel during playbook execution.
@@ -56,7 +57,7 @@ def __init__(self):
 
         if not HAS_PRETTYTABLE:
             self.disabled = True
-            self.display.warning('The `prettytable` python module is not installed. '
+            self._display.warning('The `prettytable` python module is not installed. '
                           'Disabling the HipChat callback plugin.')
 
         self.msg_uri = 'https://api.hipchat.com/v1/rooms/message'
@@ -67,7 +68,7 @@ def __init__(self):
 
         if self.token is None:
             self.disabled = True
-            self.display.warning('HipChat token could not be loaded. The HipChat '
+            self._display.warning('HipChat token could not be loaded. The HipChat '
                           'token can be provided using the `HIPCHAT_TOKEN` '
                           'environment variable.')
 
@@ -91,8 +92,7 @@ def send_msg(self, msg, msg_format='text', color='yellow', notify=False):
             response = open_url(url, data=urllib.urlencode(params))
             return response.read()
         except:
-            self.display.warning('Could not submit message to hipchat')
-
+            self._display.warning('Could not submit message to hipchat')
 
     def v2_playbook_on_play_start(self, play):
         """Display Playbook and play start messages"""


Test patch: