<div dir="ltr"><div>Hi,</div><div><br></div><div>Actually this discussion prompted me to investigate more how to optimize containers setup on a large number of hosts. As I saw from action plugin work, it still copies the module file each loop cycle, which is not very efficient behavior. That's why I started work on a podman container module which can start a bunch of containers in one call and accepts a list of containers as an input. In this case the module file will be transferred to the remote host only once and all containers execution will be done by python on the remote host.<br>That way we'll avoid unnecessary establishing connections, copying files, setting permissions etc what happens every time we cycle over data. It will be done only once.</div><div>I'll send a patch soon for review.</div><div><br></div><div>Thanks</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 4, 2020 at 12:35 PM Bogdan Dobrelya <<a href="mailto:bdobreli@redhat.com">bdobreli@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 8/3/20 9:28 PM, Alex Schultz wrote:<br>
> On Mon, Aug 3, 2020 at 6:34 AM Bogdan Dobrelya <<a href="mailto:bdobreli@redhat.com" target="_blank">bdobreli@redhat.com</a>> wrote:<br>
>><br>
>> On 8/3/20 12:36 PM, Sagi Shnaidman wrote:<br>
>>> Hi, Bogdan<br>
>>><br>
>>> thanks for raising this up, although I'm not sure I understand what it<br>
>>> is the problem with using action plugins.<br>
>>> Action plugins are well known official extensions for Ansible, as any<br>
>>> other plugins - callback, strategy, inventory etc [1]. It is not any<br>
>>> hack or unsupported workaround, it's a known and official feature of<br>
>>> Ansible. Why can't we use it? What makes it different from filter,<br>
>><br>
>> I believe the cases that require the use of those should be justified.<br>
>> For the given example, that manages containers in a loop via calling a<br>
>> module, what the written custom callback plugin buys for us? That brings<br>
>> code to maintain, extra complexity, like handling possible corner cases<br>
>> in async mode, dry-run mode etc. But what is justification aside of<br>
>> looks handy?<br>
> <br>
> I disagree that we shouldn't use action plugins or modules.  Tasks<br>
> themselves are expensive at scale.  We saw that when we switched away<br>
> from paunch to container management in pure ansible tasks.  This<br>
> exposed that looping tasks are even more expensive and complex error<br>
> handling and workflows are better suited for modules or action plugins<br>
> than a series of tasks.  This is not something to be "fixed in<br>
> ansible".  This is the nature of the executor and strategy related<br>
> interactions.  Should everything be converted to modules and plugins?<br>
> no.  Should everything be tasks only? no.  It's a balance that must be<br>
> struck between when a specific set of complex tasks need extra data<br>
> processing or error handling.  Switching to modules or action plugins<br>
> allows us to unit test our logic. Using tasks do not have such a<br>
<br>
I can understand that ansible should not be fixed for some composition <br>
tasks what require iterations and have complex logic for its "unit of <br>
work". And such ones also should be unit tested indeed. What I do not <br>
fully understand though is then what abandoning paunch for its action <br>
plugin had bought for us in the end?<br>
<br>
Paunch was self-contained and had no external dependencies on <br>
fast-changing ansible frameworks. There was also no need for paunch to <br>
handle the ansible-specific execution strategies and nuances, like "what <br>
if that action plugin is called in async or in the check-mode?" Unit <br>
tests exited in paunch as well. It was easy to backport changes within a <br>
single code base.<br>
<br>
So, looking back retrospectively, was rewriting paunch as an action <br>
plugin a simplification of the deployment framework? Please reply to <br>
yourself honestly. It does pretty same things but differently and added <br>
external framework. It is now also self-contained action plugin, since <br>
traditional tasks cannot be used in loops for this goal because of <br>
performance reasons.<br>
<br>
To summarize, action plugins may be a good solution indeed, but perhaps <br>
we should go back and use paunch instead of ansible? Same applies for <br>
*some* other tasks? That would also provide a balance, for action <br>
plugins, tasks and common sense.<br>
<br>
> concept outside of writing complex molecule testing.   IMHO it's safer<br>
> to switch to modules/action plugins than writing task logic.<br>
> <br>
> IMHO the issue that I see with the switch to Action plugins is the<br>
> increased load on the ansible "controller" node during execution.<br>
> Modules may be better depending on the task being managed. But I<br>
> believe with unit testing, action plugins or modules provide a cleaner<br>
> and more testable solution than writing roles consisting only of<br>
> tasks.<br>
> <br>
> <br>
> <br>
>><br>
>>> lookup, inventory or any other plugin we already use?<br>
>>> Action plugins are also used wide in Ansible itself, for example<br>
>>> templates plugin is implemented with action plugin [2]. If Ansible can<br>
>>> use it, why can't we? I don't think there is something with "fixing"<br>
>>> Ansible, it's not a bug, this is a useful extension.<br>
>>> What regards the mentioned action plugin for podman containers, it<br>
>>> allows to spawn containers remotely while skipping the connection part<br>
>>> for every cycle. I'm not sure you can "fix" Ansible not to do that, it's<br>
>>> not a bug. We may not see the difference in a few hosts in CI, but it<br>
>>> might be very efficient when we deploy on 100+ hosts oro even 1000+<br>
>>> hosts. In order to evaluate this on bigger setups to understand its<br>
>>> value we configured both options - to use action plugin or usual module.<br>
>>> If better performance of action plugin will be proven, we can switch to<br>
>>> use it, if it doesn't make a difference on bigger setups - then I think<br>
>>> we can easily switch back to using an usual module.<br>
>>><br>
>>> Thanks<br>
>>><br>
>>> [1] <a href="https://docs.ansible.com/ansible/latest/plugins/plugins.html" rel="noreferrer" target="_blank">https://docs.ansible.com/ansible/latest/plugins/plugins.html</a><br>
>>> [2]<br>
>>> <a href="https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/action/template.py" rel="noreferrer" target="_blank">https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/action/template.py</a><br>
>>><br>
>>> On Mon, Aug 3, 2020 at 11:19 AM Bogdan Dobrelya <<a href="mailto:bdobreli@redhat.com" target="_blank">bdobreli@redhat.com</a><br>
>>> <mailto:<a href="mailto:bdobreli@redhat.com" target="_blank">bdobreli@redhat.com</a>>> wrote:<br>
>>><br>
>>>      There is a trend of writing action plugins, see [0], for simple things,<br>
>>>      like just calling a module in a loop. I'm not sure that is the<br>
>>>      direction<br>
>>>      TripleO should go. If ansible is inefficient in this sort of tasks<br>
>>>      without custom python code written, we should fix ansible. Otherwise,<br>
>>>      what is the ultimate goal of that trend? Is that having only action<br>
>>>      plugins in roles and playbooks?<br>
>>><br>
>>>      Please kindly asking the community to stop that, make a step back and<br>
>>>      reiterate with the taken approach. Thank you.<br>
>>><br>
>>>      [0] <a href="https://review.opendev.org/716108" rel="noreferrer" target="_blank">https://review.opendev.org/716108</a><br>
>>><br>
>>><br>
>>>      --<br>
>>>      Best regards,<br>
>>>      Bogdan Dobrelya,<br>
>>>      Irc #bogdando<br>
>>><br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> Best regards<br>
>>> Sagi Shnaidman<br>
>><br>
>><br>
>> --<br>
>> Best regards,<br>
>> Bogdan Dobrelya,<br>
>> Irc #bogdando<br>
>><br>
>><br>
> <br>
<br>
<br>
-- <br>
Best regards,<br>
Bogdan Dobrelya,<br>
Irc #bogdando<br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Best regards<br></div>Sagi Shnaidman<br></div></div>