Ansible 2.0 Beta 3 is available for testing

Hi List/James,

If you discover any errors related to this beta release, or if you see
regressions from playbooks which work on 1.9.x and prior, please open a
Github issue and be sure to mention which version you're testing.

Before opening an issue, just a probe here.

It seems that ansible 2.0 does not support multiple inventory files in
the same directory, like it did before.
I think it should work, since it is:

1- handy :slight_smile:
2- mentioned in the docs:
   "Not only is this inventory configurable, but you can also
   use multiple inventory files at the same time (explained below)"
   (note that, unless I missed it, it is not "explained below").

This being said, here is a small test setup:

$ grep elastic1 inventories/devel/*
inventories/devel/generated:elastic1 from_generated="yes"
inventories/devel/hosts:elastic1 from_hosts="yes"

So here we have two inventory files (named `generated` and `hosts`). In
each file, we define a variable for the host `elastic1` (respectively
`from_generated` and `from_hosts`) and set is to the string "yes".

With 1.9.4, all is fine:

$ ansible --version
ansible 1.9.4
configured module search path = None
$ ansible elastic1 -i inventories/devel/ -m debug -a
'msg="{{from_generated}} {{from_hosts}}"'
elastic1 | success >> {
    "msg": "yes yes"
}

Now ansible 2.0b3:

$ ansible --version
ansible 2.0.0 (detached HEAD 07b588f6c0) last updated 2015/11/16
20:52:36 (GMT +200)
$ ansible elastic1 -i inventories/devel/ -m debug -a
'msg="{{from_generated}} {{from_hosts}}"'
elastic1 | FAILED! => {
    "failed": true,
    "msg": "ERROR! 'from_hosts' is undefined"
}
$ ansible elastic1 -i inventories/devel/ -m debug -a
'msg="{{from_generated}}"'
elastic1 | SUCCESS => {
    "changed": false,
    "msg": "yes"
}

If I rename `generated` to `zippy`:

$ mv inventories/devel/generated inventories/devel/zippy
$ ansible elastic1 -i inventories/devel/ -m debug -a
'msg="{{from_generated}}"'
elastic1 | FAILED! => {
    "failed": true,
    "msg": "ERROR! 'from_generated' is undefined"
}
$ ansible elastic1 -i inventories/devel/ -m debug -a 'msg="{{from_hosts}}"'
elastic1 | SUCCESS => {
    "changed": false,
    "msg": "yes"
}

So it seems Ansible now read inventory from the first file found (sorted
alpha) and stops here.

Is this the intended behavior or should an issue be opened ?

Thanks,

M

not intended at all

I finally created some crude unit tests (https://github.com/itldo/ansible_test_var) to demonstrate
the inconsistent and seemingly random behavior
I was experiencing with inventory host variables.
The summary (if you can wade through it) is at

I believe these are relevant to the following issues:

Most importantly I would like to see behavior defined for the same host
mentioned explicitly in more than one inventory (if it is supported at all).

In particular, which of these should be true?

  • 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.

  • Dynamic Groups may be children of Static Groups.
    Thanks.
    -tim