Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

various issues with YAML hosts and multiple groups #395

Closed
emgee opened this Issue · 8 comments

3 participants

@emgee

Ansible: devel, r404c3acbbf5ed3f2f6a5a2f64cc230cd22317e15
OS: Ubuntu 12.04
Python: 2.7.3

When a host is listed both "globally" and within a group, e.g.

10.0.3.232 foo=bar

[example]
10.0.3.232

[example:vars]
domain=example.com

The 'setup' command lists it only as belonging to "ungrouped" and ignores any group vars:

        "foo": "bar", 
        "group_names": "[ungrouped]", 
        "inventory_hostname": "10.0.3.232", 
@mpdehaan
Collaborator

If a host is in multiple groups, the groups list does not seem to contain all groups. It may be all in the groups still, just that the variable is not updated.

Do not know if this also occurs in the JSON version, testing welcome.

@rylach

See the following ansible-hosts:

[qa-db-hosts]
esiqadb99
esiqagw98

[qa1-hosts]
esiqagw98

esiqagw98 has in setup"

"group_names": [
    "qa-db-hosts"
], 

it seems, that only its first group has been set.

Cheers,

R.

@rylach

Also, the template

{% if 'qa-db-hosts' in groups %}
a.b.c.d some-internal-host
{% else %}
x.y.z.v some-other-internal-host
{% endif %}

expands for esiqagw98 to

x.y.z.v some-other-internal-host

so, it seems there is some other problem with {% if 'aaa' in groups %}, not only determining complete list of groups for host.

@mpdehaan
Collaborator
@rylach

Another related issue: when you add a host to INI file more then once, you have to define every time all its variables, e.g.:

[groupA]
hostA

[groupAB]
hostA varA=A

if you use groupAB in playbook - you won't see 'varA'; you have to define it in group A or switch order of groups.

Do you agree, that it should be also fixed?

@mpdehaan
Collaborator

yes

@mpdehaan
Collaborator

fixed on devel, let me know if this works for you or not, unit tests are updated and seems good to me.

@mpdehaan mpdehaan closed this
@emgee

Was just working on this myself and came up with almost the same change. Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.