There is another way: you can put "foo: '{{ default_foo }}' in defaults, and 
only set default_foo in the per-OS variables

Antoine Jacoutot <[email protected]> napisał:
>On Thu, Jan 22, 2015 at 10:59:18AM -0800, James Martin wrote:
>>    Antoine,
>>    Let's say for example you have your foobar role, and
>>    #defaults/main.yml
>>    foobar_port: 42
>>    And let's say you have an inventory group called "foobar" which is
>a
>>    list of all your foobar hosts.
>>    By using the group_by module
>>    (http://docs.ansible.com/group_by_module.html)  in a previous
>play, you
>>    can dynamic create a group based on the OS (or any other fact)
>>    Enter code here...
>>    - group_by: key=machine_{{ ansible_distribution }}
>>    You would also have a
>>    #group_vars/machine_Ubuntu
>>    foobar_port: 43
>>    and a
>>    #group_vars/machine_CentOS
>>    foobar_port: 44
>>    That would render the 43 or 44, overriding the default role value
>and
>>    be dependent on the OS.
>
>Hi James and thanks for the quick answer.
>
>I already tried what you proposed but my issue is that the role ended
>not being self-contained.
>i.e. I had to put the default os values under
>/etc/ansible/group_vars/machine_* instead of within the role hierarchy.
>
>Or is there a way that I missed?
>Thanks.
>
>-- 
>Antoine
>
>-- 
>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/20150123095939.GD29678%40janus.obspm.bsdfrog.org.
>For more options, visit https://groups.google.com/d/optout.

-- 
Wysłane za pomocą K-9 Mail.

-- 
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/90620dec-cc86-4d85-8c2b-0f5638cba090%40email.android.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to