Bug/limitation with hosts in multiple groups

Hi,

I've not been playing with Ansible for long so I may just be
misunderstanding how it's supposed to be used. However, it seems that
there's an issue when a single host is included in multiple groups in
a hosts .ini style inventory (I haven't tested a YAML inventory yet).

Say I have the following:

    [example:vars]
    domain_name=example.com

    [example]
    example-web
    example-db

    [example-web]
    10.0.3.82

    [example-db]
    10.0.3.82

In case it helps, for the 'example' group I want the host, 10.0.3.82,
to be configured to handle the web *and* db roles. Another version of
this might split web/db between across different hosts.

When the 'setup' command is run on 10.0.3.82, /etc/ansible/setup is
written as expected but 'group_names' is missing the 'example-db'
group:

    "group_names": [
        "example",
        "example-web"
    ]

If I reverse the order of the -web and -db group definitions in the
hosts inventory then 'setup' emits example-db in place of example-web:

    "group_names": [
        "example",
        "example-db"
    ]

So, am am I doing something daft or should I submit this as an issue?

Thanks, Matt

Oh, and also ...

If the same host, 10.0.3.82, is also listed at the top of the file,
outside of any group definitions, then it only appears in the
'ungrouped' group name and any actual groups, as well as those groups'
vars, are ignored.

It might seem weird to even try that, but I wanted to assign a
variable to just that host and didn't want to repeat myself my adding
the variable everytime the host is mentioned.

- Matt

When the 'setup' command is run on 10.0.3.82, /etc/ansible/setup is
written as expected but 'group_names' is missing the 'example-db'
group:

interesting.

"group_names": [
"example",
"example-web"
]

If I reverse the order of the -web and -db group definitions in the
hosts inventory then 'setup' emits example-db in place of example-web:

"group_names": [
"example",
"example-db"
]

Please submit it. It may not get fixed in 0.4, though it will be
definitely fixed in 0.5

Would be worthwhile to test if you have the same problem with the YAML
inventory format or not.

--Michael

It seems that the code is probably just not supporting multiple groups
per host in the INI format very well yet, if you see that.

Ungrouped works like any another group, more or less.

Please submit it. It may not get fixed in 0.4, though it will be
definitely fixed in 0.5

Just submitted two issues:

#394 setup command does not include all groups for host
#395 ungrouped host ignores groups it also belongs to

From what you say, they're probably the same thing but they seem like

two nice, distinct test cases, especially with per-host vars attached.

Cheers, Matt