@Brian Coca,
   So what you are suggesting, when you say you "prefer to keep things
simple and obvious" is that you suggest keeping the import statements in
the playbook that calls the role, not really inside the role itself, is
that what I am understanding you to mean by that?

--John

On Tue, Jun 21, 2022 at 11:45 AM Brian Coca <[email protected]> wrote:

> I prefer to keep things simple and obvious, I would keep role imports
> to the play, not everyone agrees and many use complex role
> hierarchies.
>
> If it is a choice between setting 'dependencies' (which imports a role
> from a role) and import_role, I always advise to use the latter.
> reasons against dependencies:
> - it is hidden in the 'meta' so it adds 'yet another file' to find out
> the task flow
> - they execute prior to the role with a lot of rules to which
> variables and keywords are inherited
> - the dependent is also the parent, which many find counterintuitive
> - the import always happens, conditionals are appended to the
> tasks/handlers on execution
>
> with import/include:
> - inheritance is clear, set at the time of import/inclusion (import
> directly,  include via apply option)
> - with include_role you can avoid importing at all, import_role
> behaves closer to roles:/dependencies
> - finer control on when to execute
> - you can dynamically choose the role and/or entry points for the role
> (tasks_from/vars_from/etc)
>
> Currently the only advantage of dependency over include/import is that
> it is both runtime and install time so you don't need to add the role
> to 'requirements' file, which can be dealt with if we automate
> requirements file creation (some issues with dynamic role selection,
> but should work for static references).
>
> ----------
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CACVha7cJWniX7iYMVN7SmPDdvim_wVDyWD9ppnjS_xnvMN%3D3fQ%40mail.gmail.com
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAPAjob9BGF9NiLszJRo0ojx0_maOgKaLx_2bs%2BT9UWGD%3DgLn5Q%40mail.gmail.com.

Reply via email to