Skip to content

Conversation

@rsmekala
Copy link
Contributor

  • From Ansible 2.4, module_name is not passed as part of result to
    v2_runner_on_ok(). So, the current code returns a Null object without
    adding the hosts.
  • Corrected by removing usage of module_name to add hosts in
    junos_jsnapy callback plugin.

- From Ansible 2.4, module_name is not passed as part of result to
 v2_runner_on_ok(). So, the current code return a Null object without
 adding the hosts.
- Corrected by removing usage of module_name to add hosts in
 junos_jsnapy callback plugin.
@vnitinv
Copy link
Contributor

vnitinv commented May 15, 2018

From Ansible 2.4, module_name is not passed

@rsmekala Is this documented anywhere in Ansible?

@rsmekala
Copy link
Contributor Author

rsmekala commented May 15, 2018

I don't think, it is documented. But, there is an issue for this.

The current result._result['invocation'] would contain:

'invocation': {
    u 'module_args': {
      u 'baud': None,
      u 'attempts': None,
      u 'logfile': u 'ansible.log',
      u 'config_file': None,
      u 'passwd': u 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER',
      u 'logdir': None,
      u 'ssh_config': None,
      u 'host': u 'xxxx',
      u 'user': u 'xxxx',
      u 'timeout': 30,
      u 'provider': None,
      u 'action': u 'snapcheck',
      u 'console': None,
      u 'ssh_private_key_file': None,
      u 'test_files': [u 'tests/junos_jsnapy/test_junos_storage.yml'],
      u 'port': xx,
      u 'dir': u '/etc/jsnapy/testfiles',
      u 'mode': None
    }
}

I have also searched for any Ansible core callback plugins using module_name, but couldn't find any. Most of the selective callback plugins decide their action based on module_args

@vnitinv vnitinv merged commit 664aa73 into Juniper:master May 15, 2018
@jnpr-bowen
Copy link

jnpr-bowen commented May 15, 2018

A quick review of this fix show it does not limit the data collected to the juniper_junos_jsnapy module. The 'if' condition on the module_name has been removed and so the behavior with only checking the module_args['action'] could be wrong. From my own reading of the ansible core callback plugins/callbacks/mail.py (line 168), it looks like the module_name equivalent has moved to result._task.action:
`

     body = 'Playbook: %s\n' % os.path.basename(self.playbook._file_name)

     if result._task.name:

         body += 'Task: %s\n' % result._task.name

     body += 'Module: %s\n' % result._task.action

     body += 'Host: %s\n' % host

     body += '\n'

`
That is what I am working from on my callback that will present the info and error messages from the jsnapy tests.

Just found the change history that supports this related to the issue that @rsmekala referred to. The forman.py callback changed from referencing result._result['invocation']['module_name'] in release 2.3 to result._task.action in release 2.4.
Here is the pull request (and discussion) that fixed this in the forman.py callback: ansible/ansible#23587

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants