backport WinRM IPv6 escaping
* https://github.com/ansible/ansible/pull/34072
* cherry-picked from 57ed6a866f
This commit is contained in:
parent
307b9b25ca
commit
9a45611c02
2 changed files with 20 additions and 1 deletions
|
@ -46,6 +46,7 @@ Ansible Changes By Release
|
||||||
* Fix win_firewall_rule "Specified cast is invalid" error when modifying a rule with all of Domain/Public/Private profiles set (https://github.com/ansible/ansible/pull/34383)
|
* Fix win_firewall_rule "Specified cast is invalid" error when modifying a rule with all of Domain/Public/Private profiles set (https://github.com/ansible/ansible/pull/34383)
|
||||||
* Fix case for multilib when installing from a file in the yum module
|
* Fix case for multilib when installing from a file in the yum module
|
||||||
(https://github.com/ansible/ansible/pull/32236)
|
(https://github.com/ansible/ansible/pull/32236)
|
||||||
|
* Fix WinRM parsing/escaping of IPv6 addresses (https://github.com/ansible/ansible/pull/34072)
|
||||||
|
|
||||||
<a id="2.4.2"></a>
|
<a id="2.4.2"></a>
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,13 @@ try:
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
HAS_XMLTODICT = False
|
HAS_XMLTODICT = 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:
|
try:
|
||||||
from __main__ import display
|
from __main__ import display
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -203,7 +210,18 @@ class Connection(ConnectionBase):
|
||||||
'''
|
'''
|
||||||
display.vvv("ESTABLISH WINRM CONNECTION FOR USER: %s on PORT %s TO %s" %
|
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)
|
(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, '', ''))
|
endpoint = urlunsplit((self._winrm_scheme, netloc, self._winrm_path, '', ''))
|
||||||
errors = []
|
errors = []
|
||||||
for transport in self._winrm_transport:
|
for transport in self._winrm_transport:
|
||||||
|
|
Loading…
Reference in a new issue