mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 10:51:24 -07:00
Module basic.py to create parent dirs of tmpdir if needed (#40201)
* Module basic.py to create parent dirs of tmpdir if needed * Added warning to dir creation * Assert if make_dirs was called or not in unit tests
This commit is contained in:
parent
5df370243d
commit
5c39c3b2d1
2 changed files with 37 additions and 2 deletions
|
@ -938,6 +938,14 @@ class AnsibleModule(object):
|
|||
# clean it up once finished.
|
||||
if self._tmpdir is None:
|
||||
basedir = os.path.expanduser(os.path.expandvars(self._remote_tmp))
|
||||
if not os.path.exists(basedir):
|
||||
self.warn("Module remote_tmp %s did not exist and was created "
|
||||
"with a mode of 0700, this may cause issues when "
|
||||
"running as another user. To avoid this, create the "
|
||||
"remote_tmp dir with the correct permissions "
|
||||
"manually" % basedir)
|
||||
os.makedirs(basedir, mode=0o700)
|
||||
|
||||
basefile = "ansible-moduletmp-%s-" % time.time()
|
||||
tmpdir = tempfile.mkdtemp(prefix=basefile, dir=basedir)
|
||||
if not self._keep_remote_files:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue