Re: [ansible-project] action_plugin/ vs library/ module

2016-01-27 Thread Mike Biancaniello

IYI, my eventual solution involves creating a blank change-mgmt ticket with 
a callback_plugin in init(). I then store the ticket number that is created 
in __main__.cli.ticket_number.
Then, the first pre-task of my playbook calls my action_plugin to read the 
ticket_number from __main__.cli and update the ticket with the actual data 
specific to the playbook that is being run.

I'm not sure I'm completely satisfied with this solution, but it does seem 
to work.



On Tuesday, January 26, 2016 at 1:22:01 PM UTC-5, Mike Biancaniello wrote:
>
> Ok, so the problem I'm having in making this a callback is that I want to 
> open a ticket on playbook start and close it on stats. 
>
> In order to open the ticket, I need certain information that will be 
> specific to the playbook being run. The only way I can find to pass vars is 
> through play_vars, which are only available in v2_playbook_on_play_start 
> through play.get_vars().
> These vars are only those that are set in the play itself, which excludes 
> vars defined in vars_files (play.get_vars_files() returns a list of files 
> which I would then need to read).
>
> I feel like I'm missing something. Is there a better way that I can pass 
> variables to a callback_plugin?
>
> The best I can find so far is to grab them from TaskResult['invocation'] 
> *after* the first task is run (then keep track of the fact that I've 
> already opened a ticket and not open a new one for every task).
>
>
>

-- 
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/796887d1-9e14-4b15-a28b-f82987d54c45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] action_plugin/ vs library/ module

2016-01-26 Thread Mike Biancaniello
Ok, so the problem I'm having in making this a callback is that I want to 
open a ticket on playbook start and close it on stats. 

In order to open the ticket, I need certain information that will be 
specific to the playbook being run. The only way I can find to pass vars is 
through play_vars, which are only available in v2_playbook_on_play_start 
through play.get_vars().
These vars are only those that are set in the play itself, which excludes 
vars defined in vars_files (play.get_vars_files() returns a list of files 
which I would then need to read).

I feel like I'm missing something. Is there a better way that I can pass 
variables to a callback_plugin?

The best I can find so far is to grab them from TaskResult['invocation'] 
*after* the first task is run (then keep track of the fact that I've 
already opened a ticket and not open a new one for every task).


-- 
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/583ce6cf-d400-418a-8977-f4b9aabe3917%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] action_plugin/ vs library/ module

2016-01-22 Thread Peter Sprygada
>From the sounds of it, developing a callback might be more appropriate.

http://docs.ansible.com/ansible/developing_plugins.html#callbacks

On Fri, Jan 22, 2016 at 1:13 PM, Mike Biancaniello 
wrote:

> So, it looks like, in my case, I'll want an action plugin since I don't
> really need anything run on a remote machine and I'll need access to the
> results of the playbook.
>
> --
> 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/50c9e5cb-3182-425a-a83f-a0b7a9b96bc5%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAEkdrMjHhYq8P_YQmBg-mjEgOkhaUyHbzhLwNfk4XTRE-cz%2BEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] action_plugin/ vs library/ module

2016-01-22 Thread Mike Biancaniello
So, it looks like, in my case, I'll want an action plugin since I don't 
really need anything run on a remote machine and I'll need access to the 
results of the playbook.

-- 
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/50c9e5cb-3182-425a-a83f-a0b7a9b96bc5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] action_plugin/ vs library/ module

2016-01-22 Thread Mike Biancaniello
I actually started out to create a callback that triggered on change, but 
after some internal discussion, decided that I didn't want it to fire after 
each task, but rather, wanted to run it one time in the beginning and once 
at the end, so I figured that calling it as a task would be more 
appropriate.

That said, one future enhancement will be to open the ticket at the 
beginning, then update it after each changed task, in which case, I plan to 
use module tasks to create and close the ticket and then use a 
callback_plugin to update the ticket with results as they come in.  Of 
course, if I've already written a module, I could set the updates to run as 
a handler task on change.

-- 
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/71e628c7-e6af-4ee8-8ff4-e52d46c047b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] action_plugin/ vs library/ module

2016-01-22 Thread Mike Biancaniello
I also notice that there seem to be a lot of action_plugins for core 
modules.

It doesn't look like modules have access to ansible __main__ data (e.g. if 
--diff was passed on the cmdline). If I need that data, might I need an 
action_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/6859434e-4287-4f77-93c8-c82992f34c87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] action_plugin/ vs library/ module

2016-01-22 Thread Mike Biancaniello
Perhaps. I'll probably build both and see which feels better. I need to be 
able to set vars for the plugin/module to use that might be different for 
each playbook. The callback_plugins have access to vars through the 
'invocation' in res, right? I'll also need access to all of the diffs, so 
I'll need to capture and then reference them in on_stat.

All other things being equal, this may come down to style and which 
playbook is easiest for people to understand and work with. Of course, most 
likely, in either case, my playbook would probably look something like 
this, no matter which option I choose:

---
  vars:
config_mgmt:
  opt1: val1
  opt2: val2
  opt3: val3


  roles:
  - { 'role':'config_mgmt','setup_vars':config_mgmt }





-- 
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/5066a050-f1ed-4eab-89d1-36ca463fd856%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] action_plugin/ vs library/ module

2016-01-22 Thread Brian Coca
It still sounds like you want a callback, you can just implement the
on_start and on_stat methods and ignore all the intermediate actions


-- 
Brian Coca

-- 
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/CAJ5XC8k%3DZ1VkCeGB5iCarUN-hqodLssQxGaimLse8F3mi7PiDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] action_plugin/ vs library/ module

2016-01-21 Thread Brian Coca
99% of the time you want a module, action plugins normally are created
when you need to do work on the 'master' machine.




-- 
Brian Coca

-- 
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/CAJ5XC8mdt17tZB%2Bp3BK38xDmj%2Br59vMChaqYFs3%2BPVofNPVOvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.