mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02: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
|
@ -25,7 +25,7 @@ with the Ansible package, but can be installed by running the following::
|
|||
Authentication Options
|
||||
``````````````````````
|
||||
When connecting to a Windows host, there are several different options that can be used
|
||||
when authentication with an account. The authentication type may be set on inventory
|
||||
when authenticating with an account. The authentication type may be set on inventory
|
||||
hosts or groups with the ``ansible_winrm_transport`` variable.
|
||||
|
||||
The following matrix is a high level overview of the options:
|
||||
|
@ -581,7 +581,6 @@ When setting up the inventory, the following variables are required::
|
|||
|
||||
# it is suggested that these be encrypted with ansible-vault:
|
||||
# ansible-vault edit group_vars/windows.yml
|
||||
|
||||
ansible_connection: winrm
|
||||
|
||||
# may also be passed on the command-line via --user
|
||||
|
@ -657,6 +656,29 @@ for each authentication option. See the section on authentication above for more
|
|||
encryption done over TLS. The WinRM payload is still encrypted with TLS
|
||||
when run over HTTPS, even if ``ansible_winrm_message_encryption=never``.
|
||||
|
||||
IPv6 Addresses
|
||||
``````````````
|
||||
IPv6 addresses can be used instead of IPv4 addresses or hostnames. This option
|
||||
is normally set in an inventory. Ansible will attempt to parse the address
|
||||
using the `ipaddress <https://docs.python.org/3/library/ipaddress.html>`_
|
||||
package and pass to pywinrm correctly.
|
||||
|
||||
When defining a host using an IPv6 address, just add the IPv6 address as you
|
||||
would an IPv4 address or hostname::
|
||||
|
||||
[windows-server]
|
||||
2001:db8::1
|
||||
|
||||
[windows-server:vars]
|
||||
ansible_user=username
|
||||
ansible_password=password
|
||||
ansible_connection=winrm
|
||||
|
||||
|
||||
.. Note:: The ipaddress library is only included by default in Python 3.x. To
|
||||
use IPv6 addresses in Python 2.6 and 2.7, make sure to run
|
||||
``pip install ipaddress`` which installs a backported package.
|
||||
|
||||
Limitations
|
||||
```````````
|
||||
Due to the design of the WinRM protocol , there are a few limitations
|
||||
|
|
|
@ -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…
Reference in a new issue