diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2022-08-03 19:59:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-03 19:59:53 +0300 |
commit | cbec27fefc543258ecf3f71746551247d7f20d3a (patch) | |
tree | c0c6938b2346ed5bd70e104bb11b5c43d6a23900 | |
parent | 2aa3cc9e40f46aa9071060052a68c2e82605a9e4 (diff) |
chmod aix errors with 255 is not unreachable (#78249) (#78356)
* chmod aix errors with 255 is not unreachable
fixes #78210
* added another 'aix chmod msg'
check stderr also
(cherry picked from commit c135a47f44fc6af816a5669499fa79b6cce69517)
-rw-r--r-- | changelogs/fragments/aix_chmod_255.yml | 2 | ||||
-rw-r--r-- | lib/ansible/plugins/connection/ssh.py | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/changelogs/fragments/aix_chmod_255.yml b/changelogs/fragments/aix_chmod_255.yml new file mode 100644 index 00000000000..b4b6aea2e14 --- /dev/null +++ b/changelogs/fragments/aix_chmod_255.yml @@ -0,0 +1,2 @@ +bugfixes: + - Avoid 'unreachable' error when chmod on AIX has 255 as return code. diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index d0c329ff487..e3b7cec68cd 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -22,6 +22,8 @@ DOCUMENTATION = ''' notes: - Many options default to C(None) here but that only means we do not override the SSH tool's defaults and/or configuration. For example, if you specify the port in this plugin it will override any C(Port) entry in your C(.ssh/config). + - The ssh CLI tool uses return code 255 as a 'connection error', this can conflict with commands/tools that + also return 255 as an error code and will look like an 'unreachable' condition or 'connection error' to this plugin. options: host: description: Hostname/IP to connect to. @@ -389,10 +391,12 @@ from ansible.utils.path import unfrackpath, makedirs_safe display = Display() - +# error messages that indicate 255 return code is not from ssh itself. b_NOT_SSH_ERRORS = (b'Traceback (most recent call last):', # Python-2.6 when there's an exception - # while invoking a script via -m - b'PHP Parse error:', # Php always returns error 255 + # while invoking a script via -m + b'PHP Parse error:', # Php always returns with error + b'chmod: invalid mode', # chmod, but really only on AIX + b'chmod: A flag or octal number is not correct.', # chmod, other AIX ) SSHPASS_AVAILABLE = None @@ -437,7 +441,8 @@ def _handle_error(remaining_retries, command, return_tuple, no_log, host, displa if return_tuple[0] == 255: SSH_ERROR = True for signature in b_NOT_SSH_ERRORS: - if signature in return_tuple[1]: + # 1 == stout, 2 == stderr + if signature in return_tuple[1] or signature in return_tuple[2]: SSH_ERROR = False break |