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

'invocation' to use from callback plugin is missing in a result. #12869

Closed
shirou opened this issue Oct 22, 2015 · 5 comments
Closed

'invocation' to use from callback plugin is missing in a result. #12869

shirou opened this issue Oct 22, 2015 · 5 comments
Assignees
Labels
bug This issue/PR relates to a bug.
Milestone

Comments

@shirou
Copy link
Contributor

shirou commented Oct 22, 2015

Issue Type:
Bug Report or Feature Idea

Ansible Version:

ansible 2.0.0 (09899b7, latest head)

Ansible Configuration:

Nothing special

Environment:

Mac

Summary:

'invocation' is not produced in a callback plugin, result._result

Because, I want to log a module name by using callback plugin. 'invocation' is always included in a result at v1, but it seems v2 not include it. (I want to run datadog-callback on v2)

I found @jimi-c said "I believe invocation was always in the output" at issue #12787. Could you add invocation into a result?

Steps To Reproduce:

prepare callback module.

    def v2_runner_on_failed(self, result, ignore_errors=False):
        print('invocation' in result._result)
Expected Results:

True

Actual Results:

False

@bcoca bcoca added this to the v2 milestone Oct 22, 2015
@abadger abadger self-assigned this Oct 22, 2015
@abadger
Copy link
Contributor

abadger commented Oct 22, 2015

Working on this now.

@abadger
Copy link
Contributor

abadger commented Oct 22, 2015

I think this branch should fix the issue for you now: https://github.com/ansible/ansible/commits/invocation-fix

I've discovered some ways in which this behaving differently depending on which module is being invoked, though, so I'm going to be doing some more work on this before it gets merged to devel.

@abadger
Copy link
Contributor

abadger commented Oct 22, 2015

Okay, the above set of commits should fix invocation's presence for all modules! Test it out and open a new bug if it doesn't work for some reason.

Closing This Ticket

Hi!

We believe recent commits (likely detailed above) should resolve this question or problem for you.

This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular
issue is resolved.

Thank you!

@shirou
Copy link
Contributor Author

shirou commented Oct 23, 2015

I confirmed my callback plugin works now. Thank you so much!

@larsks
Copy link
Contributor

larsks commented Oct 23, 2015

Commit 2e87c1f breaks the ansible command, which now says:

$ ansible localhost -m ping
 [WARNING]: Error when using <bound method CallbackModule.v2_runner_on_ok of
</home/lars/src/ansible/lib/ansible/plugins/callback/minimal.CallbackModule object at 0x7fa2ca32df10>>:
'TaskResult' object has no attribute 'copy'

And indeed, the TaskResult object has no copy method. This does not seem to impact ansible-playbook.

photoninger pushed a commit to photoninger/ansible that referenced this issue Oct 26, 2015
* Fix the task_vars parameter to not default to a mutable type (dict)
* Implement invocation in the base class's run() method have each action
  module call the run() method's implemention in the base class.
* Return values from the action plugins' run() method takes the return
  value from the base class run() method into account so that invocation
  makes its way to the output.

Fixes ansible#12869
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@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
bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

5 participants