From daeff35943ccef1e0c4d838dbbb8249534e5db99 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Thu, 11 Jun 2026 14:06:34 -0400 Subject: [PATCH] Use errno symbol instead of hardcoded value in wait_for (#87087) (#87093) (cherry picked from commit d772fe65b73e3032f88a9915111b58e743af9d9f) --- changelogs/fragments/87087-wait_for-errno-constant.yml | 2 ++ lib/ansible/modules/wait_for.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/87087-wait_for-errno-constant.yml diff --git a/changelogs/fragments/87087-wait_for-errno-constant.yml b/changelogs/fragments/87087-wait_for-errno-constant.yml new file mode 100644 index 00000000000..92008aff8b0 --- /dev/null +++ b/changelogs/fragments/87087-wait_for-errno-constant.yml @@ -0,0 +1,2 @@ +bugfixes: + - wait_for - use ``errno.ENOENT`` symbolic constant instead of hardcoded value for improved code portability. diff --git a/lib/ansible/modules/wait_for.py b/lib/ansible/modules/wait_for.py index 31165e78f55..ffdf1d3cf7f 100644 --- a/lib/ansible/modules/wait_for.py +++ b/lib/ansible/modules/wait_for.py @@ -581,7 +581,7 @@ def main(): os.stat(b_path) except OSError as e: # If anything except file not present, throw an error - if e.errno != 2: + if e.errno != errno.ENOENT: elapsed = datetime.now(timezone.utc) - start module.fail_json(msg=msg or "Failed to stat %s, %s" % (path, e.strerror), elapsed=elapsed.seconds) # file doesn't exist yet, so continue