add support for using a ipv6 in -i

testing with a ipv6 :
  ansible -u misc -i  '[2002::c23e]:22,' '*' -m ping

fail due to parsing of ':' as a separator of port/ip with ipv4.
This commit add support for properly parsing 2002::c23 and the
bracket notation [2002::ce]:2222
pull/3583/merge
Michael Scherer 11 years ago committed by James Cammarata
parent 1509e995df
commit c9d28e10ad

@ -74,9 +74,18 @@ class Inventory(object):
self.parser = None
all = Group('all')
self.groups = [ all ]
ipv6_re = re.compile('\[([a-f:A-F0-9]*)\](?::(\d+))?')
for x in host_list:
m = ipv6_re.match(x)
if m:
all.add_host(Host(m.groups()[0], m.groups()[1]))
else:
if ":" in x:
tokens = x.split(":", 1)
tokens = x.rsplit(":", 1)
# if there is ':' in the address, then this is a ipv6
if ':' in tokens[0]:
all.add_host(Host(x))
else:
all.add_host(Host(tokens[0], tokens[1]))
else:
all.add_host(Host(x))

Loading…
Cancel
Save