config manager str type vault source (#65023) (#65090)

* config manager str type vault source

* Convert vault text to_text earlier and add tests

(cherry picked from commit 7092c196ed)
pull/65504/head
Jordan Borean 5 years ago committed by Matt Davis
parent 3d3dbd6e7b
commit 87d9a088d0

@ -0,0 +1,2 @@
bugfixes:
- Fix string parsing of inline vault strings for plugin config variable sources

@ -29,6 +29,7 @@ from ansible.module_utils.six import PY3, string_types
from ansible.module_utils.six.moves import configparser from ansible.module_utils.six.moves import configparser
from ansible.module_utils.parsing.convert_bool import boolean from ansible.module_utils.parsing.convert_bool import boolean
from ansible.parsing.quoting import unquote from ansible.parsing.quoting import unquote
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode
from ansible.utils import py3compat from ansible.utils import py3compat
from ansible.utils.path import cleanup_tmp_file, makedirs_safe, unfrackpath from ansible.utils.path import cleanup_tmp_file, makedirs_safe, unfrackpath
@ -151,7 +152,7 @@ def ensure_type(value, value_type, origin=None):
# defaults to string type # defaults to string type
elif isinstance(value, string_types): elif isinstance(value, string_types):
value = unquote(value) value = unquote(to_text(value, errors='surrogate_or_strict'))
if errmsg: if errmsg:
raise ValueError('Invalid type provided for "%s": %s' % (errmsg, to_native(value))) raise ValueError('Invalid type provided for "%s": %s' % (errmsg, to_native(value)))
@ -395,7 +396,11 @@ class ConfigManager(object):
except UnicodeEncodeError: except UnicodeEncodeError:
self.WARNINGS.add(u'value for config entry {0} contains invalid characters, ignoring...'.format(to_text(name))) self.WARNINGS.add(u'value for config entry {0} contains invalid characters, ignoring...'.format(to_text(name)))
continue continue
if temp_value is not None: # only set if env var is defined if temp_value is not None: # only set if entry is defined in container
# inline vault variables should be converted to a text string
if isinstance(temp_value, AnsibleVaultEncryptedUnicode):
temp_value = to_text(temp_value, errors='surrogate_or_strict')
value = temp_value value = temp_value
origin = name origin = name

@ -21,20 +21,30 @@ options:
description: description:
- The hostname or IP address of the remote host. - The hostname or IP address of the remote host.
default: inventory_hostname default: inventory_hostname
type: str
vars: vars:
- name: ansible_host - name: ansible_host
- name: ansible_psrp_host - name: ansible_psrp_host
remote_user: remote_user:
description: description:
- The user to log in as. - The user to log in as.
type: str
vars: vars:
- name: ansible_user - name: ansible_user
- name: ansible_psrp_user - name: ansible_psrp_user
remote_password:
description: Authentication password for the C(remote_user). Can be supplied as CLI option.
type: str
vars:
- name: ansible_password
- name: ansible_winrm_pass
- name: ansible_winrm_password
port: port:
description: description:
- The port for PSRP to connect on the remote target. - The port for PSRP to connect on the remote target.
- Default is C(5986) if I(protocol) is not defined or is C(https), - Default is C(5986) if I(protocol) is not defined or is C(https),
otherwise the port is C(5985). otherwise the port is C(5985).
type: int
vars: vars:
- name: ansible_port - name: ansible_port
- name: ansible_psrp_port - name: ansible_psrp_port
@ -45,11 +55,13 @@ options:
choices: choices:
- http - http
- https - https
type: str
vars: vars:
- name: ansible_psrp_protocol - name: ansible_psrp_protocol
path: path:
description: description:
- The URI path to connect to. - The URI path to connect to.
type: str
vars: vars:
- name: ansible_psrp_path - name: ansible_psrp_path
default: 'wsman' default: 'wsman'
@ -58,6 +70,7 @@ options:
- The authentication protocol to use when authenticating the remote user. - The authentication protocol to use when authenticating the remote user.
- The default, C(negotiate), will attempt to use C(Kerberos) if it is - The default, C(negotiate), will attempt to use C(Kerberos) if it is
available and fall back to C(NTLM) if it isn't. available and fall back to C(NTLM) if it isn't.
type: str
vars: vars:
- name: ansible_psrp_auth - name: ansible_psrp_auth
choices: choices:
@ -78,6 +91,7 @@ options:
- validate - validate
- ignore - ignore
default: validate default: validate
type: str
vars: vars:
- name: ansible_psrp_cert_validation - name: ansible_psrp_cert_validation
ca_cert: ca_cert:
@ -85,6 +99,7 @@ options:
- The path to a PEM certificate chain to use when validating the server's - The path to a PEM certificate chain to use when validating the server's
certificate. certificate.
- This value is ignored if I(cert_validation) is set to C(ignore). - This value is ignored if I(cert_validation) is set to C(ignore).
type: path
vars: vars:
- name: ansible_psrp_cert_trust_path - name: ansible_psrp_cert_trust_path
- name: ansible_psrp_ca_cert - name: ansible_psrp_ca_cert
@ -93,6 +108,7 @@ options:
description: description:
- The connection timeout for making the request to the remote host. - The connection timeout for making the request to the remote host.
- This is measured in seconds. - This is measured in seconds.
type: int
vars: vars:
- name: ansible_psrp_connection_timeout - name: ansible_psrp_connection_timeout
default: 30 default: 30
@ -102,6 +118,7 @@ options:
- This value must always be greater than I(operation_timeout). - This value must always be greater than I(operation_timeout).
- This option requires pypsrp >= 0.3. - This option requires pypsrp >= 0.3.
- This is measured in seconds. - This is measured in seconds.
type: int
vars: vars:
- name: ansible_psrp_read_timeout - name: ansible_psrp_read_timeout
default: 30 default: 30
@ -109,6 +126,7 @@ options:
reconnection_retries: reconnection_retries:
description: description:
- The number of retries on connection errors. - The number of retries on connection errors.
type: int
vars: vars:
- name: ansible_psrp_reconnection_retries - name: ansible_psrp_reconnection_retries
default: 0 default: 0
@ -120,6 +138,7 @@ options:
- This is measured in seconds. - This is measured in seconds.
- The C(ansible_psrp_reconnection_backoff) variable was added in Ansible - The C(ansible_psrp_reconnection_backoff) variable was added in Ansible
2.9. 2.9.
type: int
vars: vars:
- name: ansible_psrp_connection_backoff - name: ansible_psrp_connection_backoff
- name: ansible_psrp_reconnection_backoff - name: ansible_psrp_reconnection_backoff
@ -138,6 +157,7 @@ options:
even when running over TLS/HTTPS. even when running over TLS/HTTPS.
- C(never) disables any encryption checks that are in place when running - C(never) disables any encryption checks that are in place when running
over HTTP and disables any authentication encryption processes. over HTTP and disables any authentication encryption processes.
type: str
vars: vars:
- name: ansible_psrp_message_encryption - name: ansible_psrp_message_encryption
choices: choices:
@ -150,6 +170,7 @@ options:
- Set the proxy URL to use when connecting to the remote host. - Set the proxy URL to use when connecting to the remote host.
vars: vars:
- name: ansible_psrp_proxy - name: ansible_psrp_proxy
type: str
ignore_proxy: ignore_proxy:
description: description:
- Will disable any environment proxy settings and connect directly to the - Will disable any environment proxy settings and connect directly to the
@ -164,11 +185,13 @@ options:
certificate_key_pem: certificate_key_pem:
description: description:
- The local path to an X509 certificate key to use with certificate auth. - The local path to an X509 certificate key to use with certificate auth.
type: path
vars: vars:
- name: ansible_psrp_certificate_key_pem - name: ansible_psrp_certificate_key_pem
certificate_pem: certificate_pem:
description: description:
- The local path to an X509 certificate to use with certificate auth. - The local path to an X509 certificate to use with certificate auth.
type: path
vars: vars:
- name: ansible_psrp_certificate_pem - name: ansible_psrp_certificate_pem
credssp_auth_mechanism: credssp_auth_mechanism:
@ -176,6 +199,7 @@ options:
- The sub authentication mechanism to use with CredSSP auth. - The sub authentication mechanism to use with CredSSP auth.
- When C(auto), both Kerberos and NTLM is attempted with kerberos being - When C(auto), both Kerberos and NTLM is attempted with kerberos being
preferred. preferred.
type: str
choices: choices:
- auto - auto
- kerberos - kerberos
@ -208,6 +232,7 @@ options:
- Only valid when Kerberos was the negotiated auth or was explicitly set as - Only valid when Kerberos was the negotiated auth or was explicitly set as
the authentication. the authentication.
- Ignored when NTLM was the negotiated auth. - Ignored when NTLM was the negotiated auth.
type: bool
vars: vars:
- name: ansible_psrp_negotiate_delegate - name: ansible_psrp_negotiate_delegate
negotiate_hostname_override: negotiate_hostname_override:
@ -219,6 +244,7 @@ options:
- Only valid when Kerberos was the negotiated auth or was explicitly set as - Only valid when Kerberos was the negotiated auth or was explicitly set as
the authentication. the authentication.
- Ignored when NTLM was the negotiated auth. - Ignored when NTLM was the negotiated auth.
type: str
vars: vars:
- name: ansible_psrp_negotiate_hostname_override - name: ansible_psrp_negotiate_hostname_override
negotiate_send_cbt: negotiate_send_cbt:
@ -238,6 +264,7 @@ options:
the authentication. the authentication.
- Ignored when NTLM was the negotiated auth. - Ignored when NTLM was the negotiated auth.
default: WSMAN default: WSMAN
type: str
vars: vars:
- name: ansible_psrp_negotiate_service - name: ansible_psrp_negotiate_service
@ -247,6 +274,7 @@ options:
- Sets the WSMan timeout for each operation. - Sets the WSMan timeout for each operation.
- This is measured in seconds. - This is measured in seconds.
- This should not exceed the value for C(connection_timeout). - This should not exceed the value for C(connection_timeout).
type: int
vars: vars:
- name: ansible_psrp_operation_timeout - name: ansible_psrp_operation_timeout
default: 20 default: 20
@ -255,12 +283,14 @@ options:
- Sets the maximum size of each WSMan message sent to the remote host. - Sets the maximum size of each WSMan message sent to the remote host.
- This is measured in bytes. - This is measured in bytes.
- Defaults to C(150KiB) for compatibility with older hosts. - Defaults to C(150KiB) for compatibility with older hosts.
type: int
vars: vars:
- name: ansible_psrp_max_envelope_size - name: ansible_psrp_max_envelope_size
default: 153600 default: 153600
configuration_name: configuration_name:
description: description:
- The name of the PowerShell configuration endpoint to connect to. - The name of the PowerShell configuration endpoint to connect to.
type: str
vars: vars:
- name: ansible_psrp_configuration_name - name: ansible_psrp_configuration_name
default: Microsoft.PowerShell default: Microsoft.PowerShell
@ -579,7 +609,7 @@ if ($bytes_read -gt 0) {
def _build_kwargs(self): def _build_kwargs(self):
self._psrp_host = self.get_option('remote_addr') self._psrp_host = self.get_option('remote_addr')
self._psrp_user = self.get_option('remote_user') self._psrp_user = self.get_option('remote_user')
self._psrp_pass = self._play_context.password self._psrp_pass = self.get_option('remote_password')
protocol = self.get_option('protocol') protocol = self.get_option('protocol')
port = self.get_option('port') port = self.get_option('port')

@ -25,6 +25,7 @@ DOCUMENTATION = """
vars: vars:
- name: ansible_host - name: ansible_host
- name: ansible_winrm_host - name: ansible_winrm_host
type: str
remote_user: remote_user:
keywords: keywords:
- name: user - name: user
@ -34,6 +35,14 @@ DOCUMENTATION = """
vars: vars:
- name: ansible_user - name: ansible_user
- name: ansible_winrm_user - name: ansible_winrm_user
type: str
remote_password:
description: Authentication password for the C(remote_user). Can be supplied as CLI option.
vars:
- name: ansible_password
- name: ansible_winrm_pass
- name: ansible_winrm_password
type: str
port: port:
description: description:
- port for winrm to connect on remote target - port for winrm to connect on remote target
@ -53,11 +62,13 @@ DOCUMENTATION = """
choices: [http, https] choices: [http, https]
vars: vars:
- name: ansible_winrm_scheme - name: ansible_winrm_scheme
type: str
path: path:
description: URI path to connect to description: URI path to connect to
default: '/wsman' default: '/wsman'
vars: vars:
- name: ansible_winrm_path - name: ansible_winrm_path
type: str
transport: transport:
description: description:
- List of winrm transports to attempt to to use (ssl, plaintext, kerberos, etc) - List of winrm transports to attempt to to use (ssl, plaintext, kerberos, etc)
@ -71,6 +82,7 @@ DOCUMENTATION = """
default: kinit default: kinit
vars: vars:
- name: ansible_winrm_kinit_cmd - name: ansible_winrm_kinit_cmd
type: str
kerberos_mode: kerberos_mode:
description: description:
- kerberos usage mode. - kerberos usage mode.
@ -83,6 +95,7 @@ DOCUMENTATION = """
choices: [managed, manual] choices: [managed, manual]
vars: vars:
- name: ansible_winrm_kinit_mode - name: ansible_winrm_kinit_mode
type: str
connection_timeout: connection_timeout:
description: description:
- Sets the operation and read timeout settings for the WinRM - Sets the operation and read timeout settings for the WinRM
@ -94,6 +107,7 @@ DOCUMENTATION = """
pywinrm. pywinrm.
vars: vars:
- name: ansible_winrm_connection_timeout - name: ansible_winrm_connection_timeout
type: int
""" """
import base64 import base64
@ -205,7 +219,7 @@ class Connection(ConnectionBase):
# starting the WinRM connection # starting the WinRM connection
self._winrm_host = self.get_option('remote_addr') self._winrm_host = self.get_option('remote_addr')
self._winrm_user = self.get_option('remote_user') self._winrm_user = self.get_option('remote_user')
self._winrm_pass = self._play_context.password self._winrm_pass = self.get_option('remote_password')
self._winrm_port = self.get_option('port') self._winrm_port = self.get_option('port')

@ -13,6 +13,7 @@ import pytest
from ansible.config.manager import ConfigManager, Setting, ensure_type, resolve_path, get_config_type from ansible.config.manager import ConfigManager, Setting, ensure_type, resolve_path, get_config_type
from ansible.errors import AnsibleOptionsError, AnsibleError from ansible.errors import AnsibleOptionsError, AnsibleError
from ansible.module_utils.six import integer_types, string_types from ansible.module_utils.six import integer_types, string_types
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode
curdir = os.path.dirname(__file__) curdir = os.path.dirname(__file__)
cfg_file = os.path.join(curdir, 'test.cfg') cfg_file = os.path.join(curdir, 'test.cfg')
@ -117,3 +118,16 @@ class TestConfigManager:
self.manager._read_config_yaml_file(os.path.join(curdir, 'test_non_existent.yml')) self.manager._read_config_yaml_file(os.path.join(curdir, 'test_non_existent.yml'))
assert "Missing base YAML definition file (bad install?)" in str(exec_info.value) assert "Missing base YAML definition file (bad install?)" in str(exec_info.value)
def test_entry_as_vault_var(self):
class MockVault:
def decrypt(self, value):
return value
vault_var = AnsibleVaultEncryptedUnicode(b"vault text")
vault_var.vault = MockVault()
actual_value, actual_origin = self.manager._loop_entries({'name': vault_var}, [{'name': 'name'}])
assert actual_value == "vault text"
assert actual_origin == "name"

@ -82,7 +82,7 @@ class TestConnectionPSRP(object):
'server': 'inventory_hostname', 'server': 'inventory_hostname',
'port': 5986, 'port': 5986,
'username': None, 'username': None,
'password': '', 'password': None,
'ssl': True, 'ssl': True,
'path': 'wsman', 'path': 'wsman',
'auth': 'negotiate', 'auth': 'negotiate',
@ -109,7 +109,7 @@ class TestConnectionPSRP(object):
'_psrp_max_envelope_size': 153600, '_psrp_max_envelope_size': 153600,
'_psrp_ignore_proxy': False, '_psrp_ignore_proxy': False,
'_psrp_operation_timeout': 20, '_psrp_operation_timeout': 20,
'_psrp_pass': '', '_psrp_pass': None,
'_psrp_path': 'wsman', '_psrp_path': 'wsman',
'_psrp_port': 5986, '_psrp_port': 5986,
'_psrp_proxy': None, '_psrp_proxy': None,
@ -157,7 +157,7 @@ class TestConnectionPSRP(object):
'server': 'inventory_hostname', 'server': 'inventory_hostname',
'port': 5986, 'port': 5986,
'username': None, 'username': None,
'password': '', 'password': None,
'ssl': True, 'ssl': True,
'path': 'wsman', 'path': 'wsman',
'auth': 'negotiate', 'auth': 'negotiate',

@ -25,7 +25,6 @@ class TestConnectionWinRM(object):
OPTIONS_DATA = ( OPTIONS_DATA = (
# default options # default options
( (
{},
{'_extras': {}}, {'_extras': {}},
{}, {},
{ {
@ -33,8 +32,8 @@ class TestConnectionWinRM(object):
'_kinit_cmd': 'kinit', '_kinit_cmd': 'kinit',
'_winrm_connection_timeout': None, '_winrm_connection_timeout': None,
'_winrm_host': 'inventory_hostname', '_winrm_host': 'inventory_hostname',
'_winrm_kwargs': {'username': None, 'password': ''}, '_winrm_kwargs': {'username': None, 'password': None},
'_winrm_pass': '', '_winrm_pass': None,
'_winrm_path': '/wsman', '_winrm_path': '/wsman',
'_winrm_port': 5986, '_winrm_port': 5986,
'_winrm_scheme': 'https', '_winrm_scheme': 'https',
@ -45,11 +44,10 @@ class TestConnectionWinRM(object):
), ),
# http through port # http through port
( (
{},
{'_extras': {}, 'ansible_port': 5985}, {'_extras': {}, 'ansible_port': 5985},
{}, {},
{ {
'_winrm_kwargs': {'username': None, 'password': ''}, '_winrm_kwargs': {'username': None, 'password': None},
'_winrm_port': 5985, '_winrm_port': 5985,
'_winrm_scheme': 'http', '_winrm_scheme': 'http',
'_winrm_transport': ['plaintext'], '_winrm_transport': ['plaintext'],
@ -58,15 +56,14 @@ class TestConnectionWinRM(object):
), ),
# kerberos user with kerb present # kerberos user with kerb present
( (
{},
{'_extras': {}, 'ansible_user': 'user@domain.com'}, {'_extras': {}, 'ansible_user': 'user@domain.com'},
{}, {},
{ {
'_kerb_managed': False, '_kerb_managed': False,
'_kinit_cmd': 'kinit', '_kinit_cmd': 'kinit',
'_winrm_kwargs': {'username': 'user@domain.com', '_winrm_kwargs': {'username': 'user@domain.com',
'password': ''}, 'password': None},
'_winrm_pass': '', '_winrm_pass': None,
'_winrm_transport': ['kerberos', 'ssl'], '_winrm_transport': ['kerberos', 'ssl'],
'_winrm_user': 'user@domain.com' '_winrm_user': 'user@domain.com'
}, },
@ -74,15 +71,14 @@ class TestConnectionWinRM(object):
), ),
# kerberos user without kerb present # kerberos user without kerb present
( (
{},
{'_extras': {}, 'ansible_user': 'user@domain.com'}, {'_extras': {}, 'ansible_user': 'user@domain.com'},
{}, {},
{ {
'_kerb_managed': False, '_kerb_managed': False,
'_kinit_cmd': 'kinit', '_kinit_cmd': 'kinit',
'_winrm_kwargs': {'username': 'user@domain.com', '_winrm_kwargs': {'username': 'user@domain.com',
'password': ''}, 'password': None},
'_winrm_pass': '', '_winrm_pass': None,
'_winrm_transport': ['ssl'], '_winrm_transport': ['ssl'],
'_winrm_user': 'user@domain.com' '_winrm_user': 'user@domain.com'
}, },
@ -90,9 +86,8 @@ class TestConnectionWinRM(object):
), ),
# kerberos user with managed ticket (implicit) # kerberos user with managed ticket (implicit)
( (
{'password': 'pass'},
{'_extras': {}, 'ansible_user': 'user@domain.com'}, {'_extras': {}, 'ansible_user': 'user@domain.com'},
{}, {'remote_password': 'pass'},
{ {
'_kerb_managed': True, '_kerb_managed': True,
'_kinit_cmd': 'kinit', '_kinit_cmd': 'kinit',
@ -106,10 +101,9 @@ class TestConnectionWinRM(object):
), ),
# kerb with managed ticket (explicit) # kerb with managed ticket (explicit)
( (
{'password': 'pass'},
{'_extras': {}, 'ansible_user': 'user@domain.com', {'_extras': {}, 'ansible_user': 'user@domain.com',
'ansible_winrm_kinit_mode': 'managed'}, 'ansible_winrm_kinit_mode': 'managed'},
{}, {'password': 'pass'},
{ {
'_kerb_managed': True, '_kerb_managed': True,
}, },
@ -117,10 +111,9 @@ class TestConnectionWinRM(object):
), ),
# kerb with unmanaged ticket (explicit)) # kerb with unmanaged ticket (explicit))
( (
{'password': 'pass'},
{'_extras': {}, 'ansible_user': 'user@domain.com', {'_extras': {}, 'ansible_user': 'user@domain.com',
'ansible_winrm_kinit_mode': 'manual'}, 'ansible_winrm_kinit_mode': 'manual'},
{}, {'password': 'pass'},
{ {
'_kerb_managed': False, '_kerb_managed': False,
}, },
@ -128,40 +121,37 @@ class TestConnectionWinRM(object):
), ),
# transport override (single) # transport override (single)
( (
{},
{'_extras': {}, 'ansible_user': 'user@domain.com', {'_extras': {}, 'ansible_user': 'user@domain.com',
'ansible_winrm_transport': 'ntlm'}, 'ansible_winrm_transport': 'ntlm'},
{}, {},
{ {
'_winrm_kwargs': {'username': 'user@domain.com', '_winrm_kwargs': {'username': 'user@domain.com',
'password': ''}, 'password': None},
'_winrm_pass': '', '_winrm_pass': None,
'_winrm_transport': ['ntlm'], '_winrm_transport': ['ntlm'],
}, },
False False
), ),
# transport override (list) # transport override (list)
( (
{},
{'_extras': {}, 'ansible_user': 'user@domain.com', {'_extras': {}, 'ansible_user': 'user@domain.com',
'ansible_winrm_transport': ['ntlm', 'certificate']}, 'ansible_winrm_transport': ['ntlm', 'certificate']},
{}, {},
{ {
'_winrm_kwargs': {'username': 'user@domain.com', '_winrm_kwargs': {'username': 'user@domain.com',
'password': ''}, 'password': None},
'_winrm_pass': '', '_winrm_pass': None,
'_winrm_transport': ['ntlm', 'certificate'], '_winrm_transport': ['ntlm', 'certificate'],
}, },
False False
), ),
# winrm extras # winrm extras
( (
{},
{'_extras': {'ansible_winrm_server_cert_validation': 'ignore', {'_extras': {'ansible_winrm_server_cert_validation': 'ignore',
'ansible_winrm_service': 'WSMAN'}}, 'ansible_winrm_service': 'WSMAN'}},
{}, {},
{ {
'_winrm_kwargs': {'username': None, 'password': '', '_winrm_kwargs': {'username': None, 'password': None,
'server_cert_validation': 'ignore', 'server_cert_validation': 'ignore',
'service': 'WSMAN'}, 'service': 'WSMAN'},
}, },
@ -169,7 +159,6 @@ class TestConnectionWinRM(object):
), ),
# direct override # direct override
( (
{},
{'_extras': {}, 'ansible_winrm_connection_timeout': 5}, {'_extras': {}, 'ansible_winrm_connection_timeout': 5},
{'connection_timeout': 10}, {'connection_timeout': 10},
{ {
@ -177,29 +166,47 @@ class TestConnectionWinRM(object):
}, },
False False
), ),
# user comes from option not play context # password as ansible_password
(
{'_extras': {}, 'ansible_password': 'pass'},
{},
{
'_winrm_pass': 'pass',
'_winrm_kwargs': {'username': None, 'password': 'pass'}
},
False
),
# password as ansible_winrm_pass
( (
{'username': 'user1'}, {'_extras': {}, 'ansible_winrm_pass': 'pass'},
{'_extras': {}, 'ansible_user': 'user2'},
{}, {},
{ {
'_winrm_user': 'user2', '_winrm_pass': 'pass',
'_winrm_kwargs': {'username': 'user2', 'password': ''} '_winrm_kwargs': {'username': None, 'password': 'pass'}
}, },
False False
) ),
# password as ansible_winrm_password
(
{'_extras': {}, 'ansible_winrm_password': 'pass'},
{},
{
'_winrm_pass': 'pass',
'_winrm_kwargs': {'username': None, 'password': 'pass'}
},
False
),
) )
# pylint bug: https://github.com/PyCQA/pylint/issues/511 # pylint bug: https://github.com/PyCQA/pylint/issues/511
# pylint: disable=undefined-variable # pylint: disable=undefined-variable
@pytest.mark.parametrize('play, options, direct, expected, kerb', @pytest.mark.parametrize('options, direct, expected, kerb',
((p, o, d, e, k) for p, o, d, e, k in OPTIONS_DATA)) ((o, d, e, k) for o, d, e, k in OPTIONS_DATA))
def test_set_options(self, play, options, direct, expected, kerb): def test_set_options(self, options, direct, expected, kerb):
winrm.HAVE_KERBEROS = kerb winrm.HAVE_KERBEROS = kerb
pc = PlayContext() pc = PlayContext()
for attr, value in play.items():
setattr(pc, attr, value)
new_stdin = StringIO() new_stdin = StringIO()
conn = connection_loader.get('winrm', pc, new_stdin) conn = connection_loader.get('winrm', pc, new_stdin)

Loading…
Cancel
Save