diff --git a/molecule/settings.py b/molecule/settings.py index a00a901..f99eccd 100644 --- a/molecule/settings.py +++ b/molecule/settings.py @@ -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", diff --git a/molecule/utils.py b/molecule/utils.py index 1b8a933..c45eb92 100644 --- a/molecule/utils.py +++ b/molecule/utils.py @@ -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