From dd2ea8ae1d536e061b62c4704b734df084f31631 Mon Sep 17 00:00:00 2001 From: pari- Date: Tue, 12 Dec 2017 09:48:55 +0100 Subject: [PATCH] files/file.py: Raise an IOError when trying to touch a file with missing intermediate directories within it's path (#33765) Fixes #33744 Signed-off-by: Patrick Ringl --- lib/ansible/modules/files/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/files/file.py b/lib/ansible/modules/files/file.py index 4b757715af..2b557c9447 100644 --- a/lib/ansible/modules/files/file.py +++ b/lib/ansible/modules/files/file.py @@ -440,7 +440,7 @@ def main(): if prev_state == 'absent': try: open(b_path, 'wb').close() - except OSError as e: + except (OSError, IOError) as e: module.fail_json(path=path, msg='Error, could not touch target: %s' % to_native(e, nonstring='simplerepr')) elif prev_state in ('file', 'directory', 'hard'): try: