This is true, it's also intentional to avoid facts clobbering explicitly
set variables.  But it's all around the same ballpark.

No, we are not adding any kind of "default_vars" module.

This doesn't even make sense as a module as "defaults/" in a roles
directory is processed by core code, it's not a module.

I'm sorry you can't have precedence every way you could possibly want it,
but it works the way it does.

You can use include_vars with conditionals or facts to easily load OS
specific variables.

It cannot be used for OS specific defaults.





On Tue, Apr 29, 2014 at 12:14 PM, Matt Willsher <[email protected]> wrote:

> In the docs on precedence, discovered facts come under inventory but the
> include_vars facts are actually higher precedence than the inventory.
>
> Being able to have a default_vars module would, I maintain, be a boon for
> reusable roles. They can be less opinionated and fit more circumstances. It
> allows for user control while not requiring configuration from the end user
> for the role to work.
>
> Is it something I could implement as a module for my own use or is the
> variable registration more ingrained than that?
>
> Thanks for your time,
> Matt
> On 29 Apr 2014 16:49, "Michael DeHaan" <[email protected]> wrote:
>
>> these variables are facts -- they override inventory variables because
>> they are at the same depth and are loaded later
>>
>>
>>
>>
>>
>>
>> On Tue, Apr 29, 2014 at 10:05 AM, Matt Willsher <[email protected]>wrote:
>>
>>>
>>> Testing on 1.5.5 they appear at the level of "most everything else" - a
>>> variable defined in a include_vars file overrides an inventory variable. If
>>> they were at the level of facts, that would be great and would all default
>>> like behaviour and overriding by more environment specific data.
>>>
>>>
>>> On 29 April 2014 13:32, Michael DeHaan <[email protected]> wrote:
>>>
>>>> include_vars creates fact scoped variables.
>>>>
>>>> Sorry, you're not going to be able to get it to work every which sort
>>>> of different way.
>>>>
>>>> I would not assume OS specific defaults *or* instead just put hosts in
>>>> a group based on the OS, if you really need that capability, and then could
>>>> use group_vars/ files to do this.
>>>>
>>>>
>>>>
>>>>
>>>> On Tue, Apr 29, 2014 at 3:05 AM, Matt Willsher <[email protected]>wrote:
>>>>
>>>>> I'd like the included vars injected with the same precedence as those
>>>>> in defaults/main.yml rather than the precedence of vars/main.yml. The
>>>>> documentation is not clear on the what precendence  include_vars get.
>>>>>
>>>>> From my testing, vars coming from include_vars have a higher
>>>>> precedence than inventory vars so they can not be overridden by inventory
>>>>> vars.
>>>>>
>>>>> Taking:
>>>>>
>>>>>
>>>>> 1. -e variables always win
>>>>> 2. then comes "most everything else"
>>>>> 3. then comes variables defined in inventory
>>>>> 4. then comes facts discovered about a system
>>>>> 5. then "role defaults", which are the most "defaulty" and lose in 
>>>>> priority to everything.
>>>>>
>>>>> I'd like the included vars to have the precedence of 5, rather than 2
>>>>>
>>>>>
>>>>> On 29 Apr 2014 00:55, "Michael DeHaan" <[email protected]> wrote:
>>>>>
>>>>> >
>>>>> > I'm a little confused by this because you seem to be saying a
>>>>> feature isn't supported that is actually part of Ansible, but it's 
>>>>> actually
>>>>> a module already in Ansible:
>>>>> >
>>>>> > http://docs.ansible.com/include_vars_module.html
>>>>> >
>>>>> > It also works with the "when" operator for per-OS variant usage.
>>>>> >
>>>>> > Were you perhaps reading an old thread talking about a language
>>>>> feature when it didn't exist?
>>>>> >
>>>>> > Sorry for confusion...
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> > On Mon, Apr 28, 2014 at 6:01 PM, Matt Willsher <[email protected]>
>>>>> wrote:
>>>>> >>
>>>>> >> Hi,
>>>>> >>
>>>>> >> I'm trying to write generic roles for particular applications and
>>>>> keep hitting across the same problem:
>>>>> >>
>>>>> >> I want to set role default based on the operating system or other
>>>>> facts, like include_vars, but this doesn't appear to be supported.
>>>>> >>
>>>>> >> The only option I see practically available for template is to use
>>>>> the template logic to handle defaults, but that, while flexible, is not as
>>>>> elegant as being able to set by-fact defaults.
>>>>> >>
>>>>> >> The code I'm working at present on is
>>>>> https://github.com/WillsherPartners/ansible-sshd , where there is a
>>>>> large set of defaults and a template.  sshd_subsystem_sftp varies 
>>>>> depending
>>>>> on OS, but I still want to give the person using the role to option to
>>>>> override the value if they see fit.
>>>>> >>
>>>>> >> Are there any plans for include_vars: (include_defaults?)
>>>>> functionality in Ansible, or is there some other way to tackle per-os
>>>>> defaults?
>>>>> >>
>>>>> >>
>>>>> >> Thanks,
>>>>> >> Matt
>>>>> >>
>>>>> >>
>>>>> >> --
>>>>> >> 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/afaeac27-07cf-4e10-8504-ade22c361540%40googlegroups.com
>>>>> .
>>>>> >> For more options, visit https://groups.google.com/d/optout.
>>>>> >
>>>>> >
>>>>> > --
>>>>> > You received this message because you are subscribed to a topic in
>>>>> the Google Groups "Ansible Project" group.
>>>>> > To unsubscribe from this topic, visit
>>>>> https://groups.google.com/d/topic/ansible-project/2VbVHrb0Xrc/unsubscribe
>>>>> .
>>>>> > To unsubscribe from this group and all its topics, 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/CA%2BnsWgwr3ukLhnDdS9%3DZjM%3D1MPVte1D4H2RAbx_h%2BmkjJiDChg%40mail.gmail.com
>>>>> .
>>>>>
>>>>> >
>>>>> > 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/CAKAnEVsDUvn0ttxxHeAFYTdiZS_7V21-yaHd%3DZRpeMhv_4by-A%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAKAnEVsDUvn0ttxxHeAFYTdiZS_7V21-yaHd%3DZRpeMhv_4by-A%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 a topic in the
>>>> Google Groups "Ansible Project" group.
>>>> To unsubscribe from this topic, visit
>>>> https://groups.google.com/d/topic/ansible-project/2VbVHrb0Xrc/unsubscribe
>>>> .
>>>> To unsubscribe from this group and all its topics, 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/CA%2BnsWgwWjMtLa01gR7zda0Tq%2BLMa8N%2B46S5TCMKeQhA3bBOXUg%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgwWjMtLa01gR7zda0Tq%2BLMa8N%2B46S5TCMKeQhA3bBOXUg%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 [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/CAKAnEVvsKZ%2Br_ms-4RDUNcS2%2B5uOz9if4nYujcVUeTZxu3Rf1w%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAKAnEVvsKZ%2Br_ms-4RDUNcS2%2B5uOz9if4nYujcVUeTZxu3Rf1w%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 a topic in the
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/ansible-project/2VbVHrb0Xrc/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/CA%2BnsWgxkUWZ9OjCFzrdd4sn4q37cgx1iTOodLSB8cvBdxis_ZA%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgxkUWZ9OjCFzrdd4sn4q37cgx1iTOodLSB8cvBdxis_ZA%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 [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/CAKAnEVuO1mhEZbqKX8mY8%3DO9g3KVfr309WtLjp274Z-M0-rW1g%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAKAnEVuO1mhEZbqKX8mY8%3DO9g3KVfr309WtLjp274Z-M0-rW1g%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 [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/CA%2BnsWgz%2Bhn79crY0sd1ipNmSMywg2Hi0RbwafFaLsVdSL5CMmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to