create sources.list.d directory if needed (#36981)

pull/46646/merge
Cyril Jouve 6 years ago committed by ansibot
parent 955579cd72
commit 05ca828619

@ -282,6 +282,11 @@ class SourcesList(object):
for filename, sources in list(self.files.items()):
if sources:
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)
f = os.fdopen(fd, 'w')

Loading…
Cancel
Save