Ansible: [WARNING]: Found both group and host with same name
Asked Answered
M

3

19

Using the ec2.py inventory script to query against my EC2 instances. I keep getting the following warning signs. How can i suppress them by fixing what's causing the issue?

[WARNING]: Found both group and host with same name: nex-1.XYZ.net
[WARNING]: Found both group and host with same name: admin-1.XYZ.net
[WARNING]: Found both group and host with same name: jenkinsmaster-1.XYZ.net
Martinsen answered 30/5, 2017 at 16:6 Comment(1)
More here on this feature here: github.com/ansible/ansible/pull/22519Denman
G
18

Spotting the reuse of the same name as host and group is easy :

[webserver]
webserver

But it might be trickier because sometimes it's just you have forgotten to add the :children in your group definition

This definition will rise a Warning :

[webservers]               # <-- 'webservers' is a group
web1
web2

[agent_x]
webservers                 # <-- 'webservers' is a host 

While this one won't :

[webservers]               # <-- 'webservers' is a group
web1
web2

[agent_x:children]
webservers                 # <-- 'webservers' is a group

Quote from ansible 2.4 documentation https://github.com/ansible/ansible/blob/stable-2.4/docs/docsite/rst/intro_inventory.rst#groups-of-groups-and-group-variables

It is also possible to make groups of groups using the :children suffix in INI or the children: entry in YAML

Meaning you have to be explicit whether the group will list hosts or groups.

Gunplay answered 1/3, 2018 at 13:42 Comment(0)
S
3

It happens because you probably have the same names into your inventory, for example this follow inventory:

[webserver]
webserver
webserver1

We have one host called webserver and the same name into group, could be a problem when you want to do something to group webserver don't you think?

If it happens when you use Dynamic Inventory like ec2.py the name probably is duplicated into your AWS envinronment, I recommend you change this.

Selfexpression answered 12/7, 2017 at 13:13 Comment(0)
S
0

Solved this problem in a very simple way: i forgot to add :children after my groupname

Sieve answered 14/1 at 17:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.