Skip to content

Commit

Permalink
Fix Ansible: [WARNING]: Found both group and host with same name
Browse files Browse the repository at this point in the history
Avoid setting group and host with the same name
  • Loading branch information
amuraru committed May 3, 2019
1 parent 1b63ad7 commit d362a19
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PyYAML==3.13
azure-common==1.1.4
azure==2.0.0rc5
msrestazure==0.4.6
jinja2<2.9
Jinja2==2.10.1
hashmerge
python-consul
hvac>=0.5.0
Expand Down
8 changes: 6 additions & 2 deletions src/ops/inventory/ec2inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,16 @@ def get_host_info(self):
def push(self, my_dict, key, element):
''' Push an element onto an array that may not have been defined in
the dict '''
if key == element:
return
group_info = my_dict.setdefault(key, [])
if isinstance(group_info, dict):
host_list = group_info.setdefault('hosts', [])
host_list.append(element)
if element not in host_list:
host_list.append(element)
else:
group_info.append(element)
if element not in group_info:
group_info.append(element)

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

0 comments on commit d362a19

Please sign in to comment.