mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
module_utils.(eos, nxos) - Support use_proxy argument (#30813)
* eos - Support use_proxy argument Running ansible with a proxy set in the environment causes the eos module to attempt to connect to devices via the proxy. To prevent this behaviour the only way is to unset the proxy out of the environment, either by wrapping the ansible calls or doing it in a piece of code executed before connect, such as a vars_module (though this is very hacky). This change allows you to set `use_proxy: no` under the provider config. The default value is set to True, which mirrors the behaviour seen today. * nexos - Support use_proxy argument Running ansible with a proxy set in the environment causes the nexos module to attempt to connect to devices via the proxy. To prevent this behaviour the only way is to unset the proxy out of the environment, either by wrapping the ansible calls or doing it in a piece of code executed before connect, such as a vars_module (though this is very hacky). This change allows you to set `use_proxy: no` under the provider config. The default value is set to True, which mirrors the behaviour seen today.
This commit is contained in:
committed by
John R Barker
parent
caf1b357aa
commit
b88304f211
@@ -50,6 +50,7 @@ eos_provider_spec = {
|
||||
'auth_pass': dict(no_log=True, fallback=(env_fallback, ['ANSIBLE_NET_AUTH_PASS'])),
|
||||
|
||||
'use_ssl': dict(default=True, type='bool'),
|
||||
'use_proxy': dict(default=True, type='bool'),
|
||||
'validate_certs': dict(default=True, type='bool'),
|
||||
'timeout': dict(type='int'),
|
||||
|
||||
@@ -292,10 +293,11 @@ class Eapi:
|
||||
|
||||
headers = {'Content-Type': 'application/json-rpc'}
|
||||
timeout = self._module.params['timeout']
|
||||
use_proxy = self._module.params['provider']['use_proxy']
|
||||
|
||||
response, headers = fetch_url(
|
||||
self._module, self._url, data=data, headers=headers,
|
||||
method='POST', timeout=timeout
|
||||
method='POST', timeout=timeout, use_proxy=use_proxy
|
||||
)
|
||||
|
||||
if headers['status'] != 200:
|
||||
|
||||
@@ -50,6 +50,7 @@ nxos_provider_spec = {
|
||||
'ssh_keyfile': dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE'])),
|
||||
|
||||
'use_ssl': dict(type='bool'),
|
||||
'use_proxy': dict(default=True, type='bool'),
|
||||
'validate_certs': dict(type='bool'),
|
||||
|
||||
'timeout': dict(type='int'),
|
||||
@@ -316,6 +317,7 @@ class Nxapi:
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
result = list()
|
||||
timeout = self._module.params['timeout']
|
||||
use_proxy = self._module.params['provider']['use_proxy']
|
||||
|
||||
for req in requests:
|
||||
if self._nxapi_auth:
|
||||
@@ -323,7 +325,7 @@ class Nxapi:
|
||||
|
||||
response, headers = fetch_url(
|
||||
self._module, self._url, data=req, headers=headers,
|
||||
timeout=timeout, method='POST'
|
||||
timeout=timeout, method='POST', use_proxy=use_proxy
|
||||
)
|
||||
self._nxapi_auth = headers.get('set-cookie')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user