On Fri, Oct 18, 2019, at 11:53 PM, Stanislav German-Evtushenko wrote: > Documentation > <https://docs.ansible.com/ansible/2.8/user_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable> > (see 4-7, 9, 10 from the list of priorities) says that playbook level > variables override an inventory ones. Can somebody explain why this is the > case? To me this is counter-intuitive and keeps leading to mistakes. > > Intuitive way would be: > > 1) role defaults (specified within the role itself) > ⇩ > 2) infrastructure defaults, e.g. datacenter level (specified in > group_vars or host_vars on the playbook level) > ⇩ > 3) inventory defaults, e.g. availability zone, or a specific project, > etc (specified in group_vars or host_vars on inventory level) > > However the fact is that 2 always overrides 3. How was it supposed to be used? >
I agree that it's not intuitive... It's also backwards from what I would expect. You can override the precedence order locally: https://docs.ansible.com/ansible/latest/reference_appendices/config.html#variable-precedence I choose not to do that, and instead forgo separating inventory from playbook group_vars. I, too, would be interested in an explanation of why the order is what it is. I've been bitten by it in the past. V/r, James Cassell -- 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/20d7e94d-3d27-473b-8c1e-0af30b5d2edb%40www.fastmail.com.
