Re: [ansible-project] callbacks with --check

2016-01-19 Thread Mike Biancaniello
worked great, thanks!

Is there a way to do this in 1.94?
For now, I added to my callback:

from ansible import __version__ as ANSIBLE_VERSION
if not ANSIBLE_VERSION.startswith('2'):
from ansible.callbacks import display
display("Logging not supported in Ansible <2.0",'red')
from ansible.callback_plugins.noop import CallbackModule



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b0fca3ff-4d26-4257-ab45-12f5ec297fa6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] callbacks with --check

2016-01-19 Thread Matt Martz
I think you can check `self.playbook.check` in a callback for 1.x.  I'm not
sure how soon you can access `self.playbook`.  It may not be accessible
until `playbook_on_start`.  I'll leave that for you to determine ;)

On Tue, Jan 19, 2016 at 3:55 PM, Mike Biancaniello 
wrote:

> worked great, thanks!
>
> Is there a way to do this in 1.94?
> For now, I added to my callback:
>
> from ansible import __version__ as ANSIBLE_VERSION
> if not ANSIBLE_VERSION.startswith('2'):
> from ansible.callbacks import display
> display("Logging not supported in Ansible <2.0",'red')
> from ansible.callback_plugins.noop import CallbackModule
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b0fca3ff-4d26-4257-ab45-12f5ec297fa6%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v80wx90P1DcnMhbMDW8d-og51i_nDBQhC9z5Khfx3GPJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] callbacks with --check

2016-01-19 Thread Mike Biancaniello
I am trying to put together a logging module to log changes, but I do not 
want to log anything when run in check-mode (because no changes were made, 
so this would be confusing to anyone reading the logs).

Is there any way to do this? I can't find any place where play_context (or 
anything else that might have that info) is passed to a callback_plugin.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a6004be9-3249-4d82-8957-ef4655580627%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] callbacks with --check

2016-01-19 Thread Matt Martz
There is an approach that Brian Coca and I have been working on which would
be to do the following:

from __main__ import cli

and then in __init__ of your callback:

if cli.options.check:
self.disabled = True

Eventually, the plan is to make `cli.options` available to all callbacks
natively via `self._options`. See
https://github.com/ansible/ansible/pull/13412/files

On Tue, Jan 19, 2016 at 12:03 PM, Mike Biancaniello 
wrote:

> I am trying to put together a logging module to log changes, but I do not
> want to log anything when run in check-mode (because no changes were made,
> so this would be confusing to anyone reading the logs).
>
> Is there any way to do this? I can't find any place where play_context (or
> anything else that might have that info) is passed to a callback_plugin.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/a6004be9-3249-4d82-8957-ef4655580627%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v8VFzR8pj%2B4_RB%3D5FqxpDwLmoRJxFd7-pH7S5s%2B_HiVDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.