[molecule] add support for MOLECULE_TMPDIR environment variable (defaulting to /var/tmp), so that user can override it
This commit is contained in:
@@ -32,9 +32,11 @@ class Constants(dict):
|
||||
def load(self):
|
||||
ETC_DIR = '/etc'
|
||||
CONFIG_FILE_NAME = 'molecule.conf'
|
||||
TMP_DIR = os.getenv("MOLECULE_TMPDIR", "/var/tmp")
|
||||
|
||||
mysettings = {
|
||||
'config_file': os.path.join(ETC_DIR, CONFIG_FILE_NAME),
|
||||
'tmp_dir': TMP_DIR,
|
||||
}
|
||||
|
||||
self.clear()
|
||||
@@ -52,6 +54,7 @@ class Configuration(dict):
|
||||
mysettings = {}
|
||||
settings = {
|
||||
'version': VERSION,
|
||||
'tmp_dir': self.Constants['tmp_dir'],
|
||||
'chroot_compressor': "/usr/bin/mksquashfs",
|
||||
'iso_builder': "/usr/bin/mkisofs",
|
||||
'mirror_syncer': "/usr/bin/rsync",
|
||||
|
||||
+5
-3
@@ -126,10 +126,12 @@ def empty_dir(dest_dir):
|
||||
|
||||
def mkdtemp(suffix=''):
|
||||
"""
|
||||
Generate a reliable temporary directory inside /var/tmp starting with
|
||||
"molecule".
|
||||
Generate a reliable temporary directory inside MOLECULE_TMPDIR
|
||||
env var (/var/tmp) starting with "molecule".
|
||||
"""
|
||||
return tempfile.mkdtemp(prefix = "molecule", dir = "/var/tmp",
|
||||
import molecule.settings
|
||||
tmp_dir = molecule.settings.Configuration()['tmp_dir']
|
||||
return tempfile.mkdtemp(prefix = "molecule", dir = tmp_dir,
|
||||
suffix = suffix)
|
||||
|
||||
# using subprocess.call to not care about wildcards
|
||||
|
||||
Reference in New Issue
Block a user