lineinfile creating underlying directory manage permission denied exception (#35794)
This commit is contained in:
parent
e46ae45b66
commit
038b281da2
1 changed files with 5 additions and 1 deletions
|
@ -238,7 +238,11 @@ def present(module, dest, regexp, line, insertafter, insertbefore, create,
|
|||
module.fail_json(rc=257, msg='Destination %s does not exist !' % dest)
|
||||
b_destpath = os.path.dirname(b_dest)
|
||||
if not os.path.exists(b_destpath) and not module.check_mode:
|
||||
os.makedirs(b_destpath)
|
||||
try:
|
||||
os.makedirs(b_destpath)
|
||||
except Exception as e:
|
||||
module.fail_json(msg='Error creating %s Error code: %s Error description: %s' % (b_destpath, e[0], e[1]))
|
||||
|
||||
b_lines = []
|
||||
else:
|
||||
f = open(b_dest, 'rb')
|
||||
|
|
Loading…
Reference in a new issue