Clarify behavior for hosts and host variables appearing in multiple (nested) inventories

Several recent issues have been posted concerning changed behavior between Ansible 1.9 and 2.0 (beta)
for host and host variables mentioned among multiple nested inventories
(i.e. static and dynamic inventories under the same inventory directory).

I’ve created a few integration tests for the interaction of hosts defined by multiple inventories
and a few of these continue to fail.

I think a part of the problem is that I don’t think the behavior is defined when a host is mentioned
by more than one inventory source. Unless is its just defined by “whatever 1.9 does”.

Issue #13187 indicates that a ansible-devel thread should be started to discuss and unresolved problems,
so this is another appeal to the core team to define the behavior for the same host
mentioned explicitly in more than one inventory.

Which of these apply?

  • Host variables defined in different inventories will be merged according to {{ some precedence rules }}.

  • Host variables defined in different inventories will be merged with conflicts resulting in an {{ error , warning, undefined manner }}.

  • Hosts may be mentioned in multiple inventories, but may have variables defined in at most one inventory

  • Hosts must not be mentioned explicitly in multiple inventories, however the groups they belong to may.

  • The ansible configuration hash_behaviour applies to inventory host variables {{ not at all, in some particluar way }}

  • Dynamic Groups may be children of Static Groups.
    Thanks

Just an update,

The second fix for #13397 allows my integration tests to pass (except for one involving conflicting variable values).
Thanks jimi-c.
In issue #13397 jimi-c says:

Hash behavior will only impact this if the vars contain sub-dictionaries.
Beyond that the expected behavior is that duplicate hosts found in a dir inventory are merged.

That is a step toward addressing the above questions.
So it sounds like the following are true:

  • The same host may be mentioned in multiple inventory sources, both as a group member and providing variable definitions.

  • Conflicting variable definitions for dictionary values (including sub-dictionaries) are controlled by the hash_behavior configuration variable. However the order that the hash_behavior is applied among inventories is undefined.

  • Conflicting variable definitions for non-dictionary values (scalar, list, or a combination) result in undefined behavior.
    For my own application, I can live with undefined behavior for conflicting variables.
    It would still be great to have an “official” response, and even better, references to documentation.

Thanks