Skip to content

Commit d362a19

Browse files
committed
Fix Ansible: [WARNING]: Found both group and host with same name
Avoid setting group and host with the same name
1 parent 1b63ad7 commit d362a19

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PyYAML==3.13
99
azure-common==1.1.4
1010
azure==2.0.0rc5
1111
msrestazure==0.4.6
12-
jinja2<2.9
12+
Jinja2==2.10.1
1313
hashmerge
1414
python-consul
1515
hvac>=0.5.0

src/ops/inventory/ec2inventory.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,16 @@ def get_host_info(self):
242242
def push(self, my_dict, key, element):
243243
''' Push an element onto an array that may not have been defined in
244244
the dict '''
245+
if key == element:
246+
return
245247
group_info = my_dict.setdefault(key, [])
246248
if isinstance(group_info, dict):
247249
host_list = group_info.setdefault('hosts', [])
248-
host_list.append(element)
250+
if element not in host_list:
251+
host_list.append(element)
249252
else:
250-
group_info.append(element)
253+
if element not in group_info:
254+
group_info.append(element)
251255

252256
def push_group(self, my_dict, key, element):
253257
''' Push a group as a child of another group. '''

0 commit comments

Comments
 (0)