mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 14:40:19 -07:00
windows: Add IPv6 address support and docs to go with it (#34072)
* windows: Add IPv6 address support and docs to go with it * minor docs fix * fixed some doc sentances
This commit is contained in:
parent
603d6122a3
commit
57ed6a866f
2 changed files with 55 additions and 15 deletions
|
@ -144,6 +144,13 @@ try:
|
|||
except ImportError as e:
|
||||
HAS_PEXPECT = False
|
||||
|
||||
# used to try and parse the hostname and detect if IPv6 is being used
|
||||
try:
|
||||
import ipaddress
|
||||
HAS_IPADDRESS = True
|
||||
except ImportError:
|
||||
HAS_IPADRESS = False
|
||||
|
||||
try:
|
||||
from __main__ import display
|
||||
except ImportError:
|
||||
|
@ -297,7 +304,18 @@ class Connection(ConnectionBase):
|
|||
'''
|
||||
display.vvv("ESTABLISH WINRM CONNECTION FOR USER: %s on PORT %s TO %s" %
|
||||
(self._winrm_user, self._winrm_port, self._winrm_host), host=self._winrm_host)
|
||||
netloc = '%s:%d' % (self._winrm_host, self._winrm_port)
|
||||
|
||||
winrm_host = self._winrm_host
|
||||
if HAS_IPADDRESS:
|
||||
display.vvvv("checking if winrm_host %s is an IPv6 address" % winrm_host)
|
||||
try:
|
||||
ipaddress.IPv6Address(winrm_host)
|
||||
except ipaddress.AddressValueError:
|
||||
pass
|
||||
else:
|
||||
winrm_host = "[%s]" % winrm_host
|
||||
|
||||
netloc = '%s:%d' % (winrm_host, self._winrm_port)
|
||||
endpoint = urlunsplit((self._winrm_scheme, netloc, self._winrm_path, '', ''))
|
||||
errors = []
|
||||
for transport in self._winrm_transport:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue