mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
create sources.list.d directory if needed (#36981)
This commit is contained in:
parent
955579cd72
commit
05ca828619
1 changed files with 5 additions and 0 deletions
|
@ -282,6 +282,11 @@ class SourcesList(object):
|
||||||
for filename, sources in list(self.files.items()):
|
for filename, sources in list(self.files.items()):
|
||||||
if sources:
|
if sources:
|
||||||
d, fn = os.path.split(filename)
|
d, fn = os.path.split(filename)
|
||||||
|
try:
|
||||||
|
os.makedirs(d)
|
||||||
|
except OSError as err:
|
||||||
|
if not os.path.isdir(d):
|
||||||
|
self.module.fail_json("Failed to create directory %s: %s" % (d, to_native(err)))
|
||||||
fd, tmp_path = tempfile.mkstemp(prefix=".%s-" % fn, dir=d)
|
fd, tmp_path = tempfile.mkstemp(prefix=".%s-" % fn, dir=d)
|
||||||
|
|
||||||
f = os.fdopen(fd, 'w')
|
f = os.fdopen(fd, 'w')
|
||||||
|
|
Loading…
Reference in a new issue