Skip to content

Instantly share code, notes, and snippets.

@apatard
Created September 14, 2020 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apatard/b037eb8313201399a33df5677bbaae64 to your computer and use it in GitHub Desktop.
Save apatard/b037eb8313201399a33df5677bbaae64 to your computer and use it in GitHub Desktop.
diff --git a/molecule_vagrant/modules/vagrant.py b/molecule_vagrant/modules/vagrant.py
index 4fdeae7..f8fad23 100644
--- a/molecule_vagrant/modules/vagrant.py
+++ b/molecule_vagrant/modules/vagrant.py
@@ -35,7 +35,6 @@ import subprocess
import sys
import molecule
-import molecule.config
import molecule.util
try:
@@ -385,7 +384,7 @@ class VagrantClient(object):
self._module = module
self._config = self._get_config()
- self._vagrantfile = self._config.driver.vagrantfile
+ self._vagrantfile = self._config["vagrantfile"]
self._vagrant = self._get_vagrant()
self._write_configs()
self._has_error = None
@@ -497,20 +496,21 @@ class VagrantClient(object):
return {}
def _get_config(self):
- molecule_file = os.environ["MOLECULE_FILE"]
-
- return molecule.config.Config(molecule_file)
+ conf = dict()
+ conf["ephdir"] = os.getenv("MOLECULE_EPHEMERAL_DIRECTORY")
+ conf["vagrantfile"] = os.path.join(conf["ephdir"], "Vagrantfile")
+ conf["vagrantfile_config"] = os.path.join(conf["ephdir"], "vagrant.yml")
+ return conf
def _write_vagrantfile(self):
template = molecule.util.render_template(
- VAGRANTFILE_TEMPLATE,
- vagrantfile_config=self._config.driver.vagrantfile_config,
+ VAGRANTFILE_TEMPLATE, vagrantfile_config=self._config["vagrantfile_config"]
)
molecule.util.write_file(self._vagrantfile, template)
def _write_vagrantfile_config(self, data):
molecule.util.write_file(
- self._config.driver.vagrantfile_config, molecule.util.safe_dump(data)
+ self._config["vagrantfile_config"], molecule.util.safe_dump(data)
)
def _write_configs(self):
@@ -586,8 +586,7 @@ class VagrantClient(object):
instance_name = self._module.params["instance_name"]
return os.path.join(
- self._config.scenario.ephemeral_directory,
- "vagrant-{}.{}".format(instance_name, __type),
+ self._config["ephdir"], "vagrant-{}.{}".format(instance_name, __type)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment