On 27/06/14 13:49, Michael DeHaan wrote:
> " For example, a munin role may ask apache role to create a
> virtualhost, if it finds apache is available."
>
> Role dependencies can include "when" statements.   The conditionals
> will be applied to each task in the role, so the parameters would need
> to be loaded first, i.e in your role dependencies:
>
> { role: apache, when: has_apache }
>
> Since these happen before the role, you would need to set "has_apache"
> via register or other means prior to including the role that had this
> dependency.
>
> However, in most cases, this is a little too complicated.
>
> Why do munin machines in your infrastructure only sometimes have
> Apache available?

I'm just thinking in terms of contributed roles. I may want to
contribute a munin role that configures a virtualhost only if it detects
the user is including a compatible apache role, because a user may want
to use my contributed munin role, but not my contributed apache.
Munin-apache is just an example. A more generalized use case: services
that may declare fail2ban jails, or monit checks if they detect the
providing roles are already included.

Nevertheless, I think I've grokked (or resigned to) ansible philosophy
and just wanted to point some things that IMHO may help it be a better tool.


>
> I'd probably try to fix that by enforcing consistency with Ansible,
> rather than making it behave too conditionally.
>
> It's almost always cleaner to say "there shall be X" and make it so,
> rather than make some things depend on the state of remote
> infrastructure, which is variable, and then you don't know what you've
> got. 
>
>
> On Fri, Jun 27, 2014 at 8:07 AM, "F.L. Jonathan Araña Cruz"
> <jonhat...@faita.net <mailto:jonhat...@faita.net>> wrote:
>
>     On 26/06/14 17:59, Michael DeHaan wrote:
>>     "Would be great to have a magic variable to obtain the path to
>>     roles tasks, to allow for things like:"
>>
>>     I feel it would be pretty esoteric and infrequently used, we tend
>>     to push back on extra magic until enough use cases for them start
>>     to appear.
>>
>>     Usually roles don't import tasks straight out of other roles, and
>>     would use role dependencies in the cases where they did.
>
>     Indeed I'd like a role to soft-depend on other. For example, a
>     munin role may ask apache role to create a virtualhost, if it
>     finds apache is available.
>
>     Other example is an apache role that may ask fail2ban role, if
>     available, to enable jails for the ports it manages.
>
>     My workaround for this is to hihack action plugins -
>     https://github.com/sbitmedia/ansible-monit#leverage-monit-in-your-roles
>
>
>
>>
>>     You should be able to know the relative pathing in nearly all
>>     cases though.
>
>     Yes, from my playbooks (or roles) I know the relative path to
>     anything, but I can't assume anythin for a role I want to contribute.
>
>
>>
>>
>>
>>
>>     On Thu, Jun 26, 2014 at 12:54 PM, "F.L. Jonathan Araña Cruz"
>>     <jonhat...@faita.net <mailto:jonhat...@faita.net>> wrote:
>>
>>         On 26/06/14 14:25, Michael DeHaan wrote:
>>>         It's not a bug.   
>>>
>>>         It's also a little weird, it's not expected that you would
>>>         manually include a task file from a role directory without
>>>         using roles, but if you wanted to, you would have to path it
>>>         in the various subdirectories.
>>
>>         Would be great to have a magic variable to obtain the path to
>>         roles tasks, to allow for things like:
>>
>>         - hosts: hosts
>>           roles:
>>             - role-apache
>>             - role-other
>>           tasks:
>>             - include:
>>         "{{roles_paths['role-apache']}}/create_virtualhost.yml"
>>         servername=example.com <http://example.com>
>>
>>         There's an issue asking for this, although a bit tangled:
>>         https://github.com/ansible/ansible/issues/6955
>>
>>>
>>>
>>>
>>>         On Wed, Jun 25, 2014 at 7:03 AM, Руслан Закиров
>>>         <r...@sports.ru <mailto:r...@sports.ru>> wrote:
>>>
>>>             Hi,
>>>
>>>             I hoped for the following to work from a playbook:
>>>
>>>             - hosts: backends
>>>               roles:
>>>                 - common
>>>                 - perl-app
>>>               tasks:
>>>                 - include: a_task_that_sits_in_xxx_role.yml
>>>
>>>             But I get:
>>>
>>>             ERROR: file could not read:
>>>             .../my-ansible/a_task_that_sits_in_xxx_role.yml
>>>
>>>             What I expected is that an include in a playbook will
>>>             search for a task to include in play's roles.
>>>
>>>             Is it a bug?
>>>
>>>             -- 
>>>             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
>>>             <mailto:ansible-project+unsubscr...@googlegroups.com>.
>>>             To post to this group, send email to
>>>             ansible-project@googlegroups.com
>>>             <mailto:ansible-project@googlegroups.com>.
>>>             To view this discussion on the web visit
>>>             
>>> https://groups.google.com/d/msgid/ansible-project/67cb019c-471b-46ca-82d0-46760f8f4677%40googlegroups.com
>>>             
>>> <https://groups.google.com/d/msgid/ansible-project/67cb019c-471b-46ca-82d0-46760f8f4677%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>>             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
>>>         <mailto:ansible-project+unsubscr...@googlegroups.com>.
>>>         To post to this group, send email to
>>>         ansible-project@googlegroups.com
>>>         <mailto:ansible-project@googlegroups.com>.
>>>         To view this discussion on the web visit
>>>         
>>> https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgw_Tu3Jbf9-JsYLp6Kc_h%3D4Vchy5jabzavuE21NRMq1rw%40mail.gmail.com
>>>         
>>> <https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgw_Tu3Jbf9-JsYLp6Kc_h%3D4Vchy5jabzavuE21NRMq1rw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>>
>>>
>>>         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
>>         <mailto:ansible-project+unsubscr...@googlegroups.com>.
>>         To post to this group, send email to
>>         ansible-project@googlegroups.com
>>         <mailto:ansible-project@googlegroups.com>.
>>         To view this discussion on the web visit
>>         
>> https://groups.google.com/d/msgid/ansible-project/53AC502A.6010300%40faita.net
>>         
>> <https://groups.google.com/d/msgid/ansible-project/53AC502A.6010300%40faita.net?utm_medium=email&utm_source=footer>.
>>
>>
>>         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
>>     <mailto:ansible-project+unsubscr...@googlegroups.com>.
>>     To post to this group, send email to
>>     ansible-project@googlegroups.com
>>     <mailto:ansible-project@googlegroups.com>.
>>     To view this discussion on the web visit
>>     
>> https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgyrBeMs%3DdvcHh821LM6HiM3PyMHRf-T2xD5vdn8Zq_Tyw%40mail.gmail.com
>>     
>> <https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgyrBeMs%3DdvcHh821LM6HiM3PyMHRf-T2xD5vdn8Zq_Tyw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>
>>
>>     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
>     <mailto:ansible-project+unsubscr...@googlegroups.com>.
>     To post to this group, send email to
>     ansible-project@googlegroups.com
>     <mailto:ansible-project@googlegroups.com>.
>     To view this discussion on the web visit
>     
> https://groups.google.com/d/msgid/ansible-project/53AD5E8E.6030205%40faita.net
>     
> <https://groups.google.com/d/msgid/ansible-project/53AD5E8E.6030205%40faita.net?utm_medium=email&utm_source=footer>.
>
>
>     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
> <mailto:ansible-project+unsubscr...@googlegroups.com>.
> To post to this group, send email to ansible-project@googlegroups.com
> <mailto:ansible-project@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzund%2BCfte7iYWB4f6ZD9GUnOkNpszk4jk6C7cR%2BD-wZA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzund%2BCfte7iYWB4f6ZD9GUnOkNpszk4jk6C7cR%2BD-wZA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> 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/53AD6C1C.4090503%40faita.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to