mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
allow for non standard hostnames
* Changed parse_addresses to throw exceptions instead of passing None * Switched callers to trap and pass through the original values. * Added very verbose notice * Look at deprecating this and possibly validate at plugin instead fixes #13608
This commit is contained in:
parent
593d80c63d
commit
75e94e0cba
5 changed files with 49 additions and 29 deletions
|
@ -53,9 +53,13 @@ class ActionModule(ActionBase):
|
|||
new_name = self._task.args.get('name', self._task.args.get('hostname', None))
|
||||
display.vv("creating host via 'add_host': hostname=%s" % new_name)
|
||||
|
||||
name, port = parse_address(new_name, allow_ranges=False)
|
||||
if not name:
|
||||
raise AnsibleError("Invalid inventory hostname: %s" % new_name)
|
||||
try:
|
||||
name, port = parse_address(new_name, allow_ranges=False)
|
||||
except:
|
||||
# not a parsable hostname, but might still be usable
|
||||
name = new_name
|
||||
port = None
|
||||
|
||||
if port:
|
||||
self._task.args['ansible_ssh_port'] = port
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue