mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Fix hostname expansion bug in inventory parser
This commit is contained in:
parent
23f2a7fc7e
commit
7fbb7e079a
3 changed files with 32 additions and 20 deletions
|
@ -93,28 +93,24 @@ class InventoryParser(object):
|
|||
hostname = tokens2[0]
|
||||
port = tokens2[1]
|
||||
|
||||
host = None
|
||||
_all_hosts = []
|
||||
if hostname in self.hosts:
|
||||
host = self.hosts[hostname]
|
||||
_all_hosts.append(host)
|
||||
hostnames = []
|
||||
if detect_range(hostname):
|
||||
hostnames = expand_hostname_range(hostname)
|
||||
else:
|
||||
if detect_range(hostname):
|
||||
_hosts = expand_hostname_range(hostname)
|
||||
for _ in _hosts:
|
||||
host = Host(name=_, port=port)
|
||||
self.hosts[_] = host
|
||||
_all_hosts.append(host)
|
||||
hostnames = [hostname]
|
||||
|
||||
for hn in hostnames:
|
||||
host = None
|
||||
if hn in self.hosts:
|
||||
host = self.hosts[hn]
|
||||
else:
|
||||
host = Host(name=hostname, port=port)
|
||||
self.hosts[hostname] = host
|
||||
_all_hosts.append(host)
|
||||
if len(tokens) > 1:
|
||||
for t in tokens[1:]:
|
||||
(k,v) = t.split("=")
|
||||
host.set_variable(k,v)
|
||||
for _ in _all_hosts:
|
||||
self.groups[active_group_name].add_host(_)
|
||||
host = Host(name=hn, port=port)
|
||||
self.hosts[hn] = host
|
||||
if len(tokens) > 1:
|
||||
for t in tokens[1:]:
|
||||
(k,v) = t.split("=")
|
||||
host.set_variable(k,v)
|
||||
self.groups[active_group_name].add_host(host)
|
||||
|
||||
# [southeast:children]
|
||||
# atlanta
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue