Accessing variables via Ansible 2.0 callback
<p>I inherited a callback plugin that was woirking with Ansible 1.9. We upgraded to 2.1 and it no longer works. </p>

<p>Looks like it's trying to access the playbook object but it's not getting passed into "v2_playbook_on_stats." My Python is rusty so I'm not sure how I can go about accessing that data. I'm tryijng to access the "extra-vars" variable but it's giving me the following error:</p>

<pre><code>[WARNING]: Failure using method (v2_playbook_on_stats) in callback plugin
(&lt;/home/deployment/scripts/playbooks-2.0/callback/log_to_mongo.CallbackModule object at 0x2b8cf90&gt;): 'NoneType'     object has no attribute 'extra_vars'
</code></pre>

<h1>code</h1>

<pre><code>class CallbackModule(object):
    """
    An ansible callback module for saving Ansible output to a database log
    """
    def __init__(self):
        self.playbook = None
        self.playbook_name = None
        self.play = None
        self.task = None

def v2_playbook_on_stats(self, stats):
    global jira_ticket
    global deployed_modules
    global ocd_job_id
    global environment_id

    deployed_modules = []
    jira_ticket = self.playbook.extra_vars['jira_ticket']
    ocd_job_id = self.playbook.extra_vars['ocd_job_id']
    environment_id = self.playbook.extra_vars['environment_id']
</code></pre>