Skip to content

Commit

Permalink
[PATCH] driver.provider.name Overrided by VAGRANT_DEFAULT_PROVIDER
Browse files Browse the repository at this point in the history
In case environment variable `VAGRANT_DEFAULT_PROVIDER` is defined (see
<https://www.vagrantup.com/docs/other/environmental-variables#vagrant_default_provider>),
our `driver.provider.name` will have no effect and always start with
above default provider as specifiied.

With python-vagrant `up()` (see
<https://github.com/pycontribs/python-vagrant/blob/main/src/vagrant/__init__.py#L310-L318>)
we could specify the target provider with `provider` option, where our
current wrapper only provide the `provision` option.

See ansible-community/molecule-vagrant#174

Signed-off-by: Wong Hoi Sing Edison <[email protected]>
  • Loading branch information
hswong3i committed May 18, 2023
1 parent 7bb0b34 commit 7c3520b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/molecule_plugins/vagrant/modules/vagrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@
class VagrantClient:
def __init__(self, module) -> None:
self._module = module
self.provider = self._module.params["provider_name"]
self.provision = self._module.params["provision"]
self.cachier = self._module.params["cachier"]

Expand Down Expand Up @@ -425,9 +426,10 @@ def up(self):
changed = False
if self._running() != len(self.instances):
changed = True
provider = self.provider
provision = self.provision
with contextlib.suppress(Exception):
self._vagrant.up(provision=provision)
self._vagrant.up(provider=provider, provision=provision)

# NOTE(retr0h): Ansible wants only one module return `fail_json`
# or `exit_json`.
Expand Down

0 comments on commit 7c3520b

Please sign in to comment.