mirror of
https://github.com/zebrajr/ansible.git
synced 2025-12-06 12:19:53 +01:00
Fix psrp - ReadTimeout exceptions now mark host as unreachable (#85974)
* psrp - ReadTimeout exceptions now mark host as unreachable * add try to _exec_psrp_script * fix indent E111 * update raise format switch to raise Exception from e Co-authored-by: Jordan Borean <jborean93@gmail.com> --------- Co-authored-by: Jordan Borean <jborean93@gmail.com>
This commit is contained in:
parent
c02f59ca3a
commit
9fcf1f7c58
2
changelogs/fragments/85966-psrp-readtimeout.yml
Normal file
2
changelogs/fragments/85966-psrp-readtimeout.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- psrp - ReadTimeout exceptions now mark host as unreachable instead of fatal (https://github.com/ansible/ansible/issues/85966)
|
||||||
|
|
@ -331,7 +331,7 @@ try:
|
||||||
from pypsrp.host import PSHost, PSHostUserInterface
|
from pypsrp.host import PSHost, PSHostUserInterface
|
||||||
from pypsrp.powershell import PowerShell, RunspacePool
|
from pypsrp.powershell import PowerShell, RunspacePool
|
||||||
from pypsrp.wsman import WSMan
|
from pypsrp.wsman import WSMan
|
||||||
from requests.exceptions import ConnectionError, ConnectTimeout
|
from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout
|
||||||
except ImportError as err:
|
except ImportError as err:
|
||||||
HAS_PYPSRP = False
|
HAS_PYPSRP = False
|
||||||
PYPSRP_IMP_ERR = err
|
PYPSRP_IMP_ERR = err
|
||||||
|
|
@ -479,11 +479,16 @@ class Connection(ConnectionBase):
|
||||||
pwsh_in_data = in_data
|
pwsh_in_data = in_data
|
||||||
display.vvv(u"PSRP: EXEC %s" % script, host=self._psrp_host)
|
display.vvv(u"PSRP: EXEC %s" % script, host=self._psrp_host)
|
||||||
|
|
||||||
rc, stdout, stderr = self._exec_psrp_script(
|
try:
|
||||||
script=script,
|
rc, stdout, stderr = self._exec_psrp_script(
|
||||||
input_data=pwsh_in_data.splitlines() if pwsh_in_data else None,
|
script=script,
|
||||||
arguments=script_args,
|
input_data=pwsh_in_data.splitlines() if pwsh_in_data else None,
|
||||||
)
|
arguments=script_args,
|
||||||
|
)
|
||||||
|
except ReadTimeout as e:
|
||||||
|
raise AnsibleConnectionFailure(
|
||||||
|
"HTTP read timeout during PSRP script execution"
|
||||||
|
) from e
|
||||||
return rc, stdout, stderr
|
return rc, stdout, stderr
|
||||||
|
|
||||||
def put_file(self, in_path: str, out_path: str) -> None:
|
def put_file(self, in_path: str, out_path: str) -> None:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user