mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 23:17:32 -02:30
Allow hostname:portnum in inventory files to be used as shorthand for the importer.
This commit is contained in:
@@ -98,11 +98,20 @@ class MemHost(object):
|
|||||||
LOGGER.debug("adding host name: %s" % name)
|
LOGGER.debug("adding host name: %s" % name)
|
||||||
assert name is not None
|
assert name is not None
|
||||||
assert inventory_base is not None
|
assert inventory_base is not None
|
||||||
# FIXME: set ansible_ssh_port if ":" in name
|
|
||||||
|
# set ansible_ssh_port if ":" in name
|
||||||
self.name = name
|
self.name = name
|
||||||
self.variables = {}
|
self.variables = {}
|
||||||
self.inventory_base = inventory_base
|
self.inventory_base = inventory_base
|
||||||
|
|
||||||
|
if name.find(":") != -1:
|
||||||
|
tokens = name.split(":")
|
||||||
|
self.name = tokens[0]
|
||||||
|
self.variables['ansible_ssh_port'] = tokens[1]
|
||||||
|
|
||||||
|
if "[" in name:
|
||||||
|
raise ImportException("block ranges like host[0:50].example.com are not yet supported by the importer")
|
||||||
|
|
||||||
host_vars = os.path.join(inventory_base, 'host_vars', name)
|
host_vars = os.path.join(inventory_base, 'host_vars', name)
|
||||||
if os.path.exists(host_vars):
|
if os.path.exists(host_vars):
|
||||||
LOGGER.debug("loading host_vars")
|
LOGGER.debug("loading host_vars")
|
||||||
|
|||||||
Reference in New Issue
Block a user