mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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:
|
||||
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