summaryrefslogtreecommitdiff
path: root/lib/ansible/module_utils
diff options
context:
space:
mode:
authorFelix Fontein <felix@fontein.de>2021-06-14 17:38:47 +0200
committerGitHub <noreply@github.com>2021-06-14 10:38:47 -0500
commit25ac5059752f22b7e9faf1c212e5005b82838f87 (patch)
tree4e761a772a27dc2e17a16dc50180c6df483d4cc0 /lib/ansible/module_utils
parent93de61a8dab85309fa0e5b2015e25995662af468 (diff)
downloadansible-25ac5059752f22b7e9faf1c212e5005b82838f87.tar.gz
Basic: don't call lstat when check_mode (#64279) (#74883)
While mode is specified in check_mode, don't call lstat. Since file may not present. Fixes: #61185 (cherry picked from commit 7099657dd7279ef2989d601251f46e7407a86fa6) Co-authored-by: Logistic Bot <logistic-bot@protonmail.com>
Diffstat (limited to 'lib/ansible/module_utils')
-rw-r--r--lib/ansible/module_utils/basic.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py
index cd2a055334..3810dc22a3 100644
--- a/lib/ansible/module_utils/basic.py
+++ b/lib/ansible/module_utils/basic.py
@@ -882,11 +882,12 @@ class AnsibleModule(object):
b_path = to_bytes(path, errors='surrogate_or_strict')
if expand:
b_path = os.path.expanduser(os.path.expandvars(b_path))
- path_stat = os.lstat(b_path)
if self.check_file_absent_if_check_mode(b_path):
return True
+ path_stat = os.lstat(b_path)
+
if not isinstance(mode, int):
try:
mode = int(mode, 8)