That's exactly the workaround I'm using now, however you can't do something
similar for 'notify'.
e.g.
notify:
- reload {{ ansible_os_family }}
doesn't work, putting a when clause on the entire block just for the sake
of using different notifiers means duplication of an entire block and again
will also increase the chatty-ness
What's the preferred way of dealing with variable notifiers?
Op dinsdag 24 juni 2014 21:16:22 UTC+2 schreef Michael DeHaan:
>
>
>
>
> On Tue, Jun 24, 2014 at 12:36 PM, Christian Thiemann <[email protected]
> <javascript:>> wrote:
>
>>
>>
>> On Tuesday, June 24, 2014 6:04:54 PM UTC+2, Michael DeHaan wrote:
>>>
>>> "It doesn't work for me (unless I create a file called
>>> roles/foobar/tasks/{{ansible_os_family}}.yml... ;-) )."
>>>
>>> So in other words, it works :)
>>>
>>
>> No, sorry, I meant literally "{{ansible_os_family}}.yml" -- it doesn't
>> seem to do templating for the included file name. I think I remember this
>> being a popular feature request some time ago, but you wrote it's important
>> that the list of tasks in a play is fixed for every host (and it's
>> determined on parsing time, not run-time). Correct me if I missed something.
>>
>
>
> Sorry, yes, It is true you can't include off inventory scoped variables
> like that.
>
> However
>
> - include: RedHat.yml
> when: ansible_os_family == 'RedHat'
>
> That works fine.
>
> include_vars is fine with such tricks, however
>
>
>
>>
>>> Also, public service announcement - Don't use ansible_pkg_mgr like that
>>> - it won't join mulitple package installs using with_items into single
>>> transactions. If you want to do a "when: ansible_pkg_mgr == 'apt'" that
>>> will still keep it going.
>>>
>>
>> Yes, in my roles I am working around that by supplying comma-separated
>> lists myself instead of using with_items. Using ansible_pkg_mgr also has
>> the disadvantage of not being able to use apt/yum/portage-specific
>> parameters, but for virtually all of my package-manager needs it is
>> sufficient -- and so, so, so much nicer in the output ;-)
>>
>>
>>>
>>>
>>>
>>> On Tue, Jun 24, 2014 at 10:31 AM, Christian Thiemann <[email protected]
>>> > wrote:
>>>
>>>> It doesn't work for me (unless I create a file called
>>>> roles/foobar/tasks/{{ansible_os_family}}.yml... ;-) ).
>>>>
>>>> I abstracted away package manager things using the ansible_pkg_mgr fact:
>>>>
>>>> - module: "{{ ansible_pkg_mgr }} name=foobar,baz,foo"
>>>>
>>>> To account for OS-specific package names, you can do something like
>>>> this:
>>>>
>>>> - module: "{{ ansible_pkg_mgr }} name={{ pkg_foobar }},{{ pkg_baz }},{{
>>>> pkg_foo }}"
>>>>
>>>> The pkg_XXX variables must be defined in vars/Debian.yml and
>>>> vars/Darwin.yml, and you do this at the top of the role:
>>>>
>>>> - include_vars: '{{ ansible_os_family }}.yml'
>>>>
>>>>
>>>>
>>>> On Tuesday, June 24, 2014 3:26:28 PM UTC+2, Michael DeHaan wrote:
>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Mon, Jun 23, 2014 at 3:25 PM, Nico K. <[email protected]> wrote:
>>>>>
>>>>>> Sure, but that's exactly the thing I would like to deal with within a
>>>>>> role, within a role however you can't perform the 'include' you stated
>>>>>> in
>>>>>> your post as "ansible_os_family" doesn't seem to evaluate.
>>>>>>
>>>>>
>>>>> This is not true.
>>>>>
>>>>> Task files in roles (main.yml) can include other files.
>>>>>
>>>>> include_vars also works as a task as I have mentioned.
>>>>>
>>>> --
>>>> 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 post to this group, send email to [email protected].
>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>> msgid/ansible-project/7712c232-8610-4b1c-a203-
>>>> 80eb50572477%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/ansible-project/7712c232-8610-4b1c-a203-80eb50572477%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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/bb084154-9377-4898-9232-7ac340af4d50%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/bb084154-9377-4898-9232-7ac340af4d50%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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/eb7816da-43b5-4543-80b0-db203409b35e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.