question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Molecule 2.22rc3: Vagrant driver regression

See original GitHub issue

Issue Type

  • Bug report

Molecule and Ansible details

Ansible: 2.8.1 Molecule 2.22rc3

Python: 2.7.12 Vagrant: 2.0.2 Virtualbox: 5.2.30r130521 Ubuntu 16.04.6 LTS x86_64

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Detail any linters or test runners used:

Desired Behavior

Running Molecule test on a sample role with a Vagrant driver and a Virtualbox provider should result in a Virtualbox VM being brought up at some point.

Actual Behaviour

Debug output snippet:

    TASK [Create molecule instance(s)] *********************************************
    task path: /usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible/playbooks/vagrant/create.yml:8
    <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: go
    <127.0.0.1> EXEC /bin/sh -c 'echo ~go && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /var/go/.ansible/tmp/ansible-tmp-1562189970.7-142759633793038 `" && echo ansible-tmp-1562189970.7-142759633793038="` echo /var/go/.ansible/tmp/ansible-tmp-1562189970.7-142759633793038 `" ) && sleep 0'
    Using module file /usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py
    <127.0.0.1> PUT /var/go/.ansible/tmp/ansible-local-10147KOol3i/tmpmVJNT9 TO /var/go/.ansible/tmp/ansible-tmp-1562189970.7-142759633793038/AnsiballZ_molecule_vagrant.py
    <127.0.0.1> EXEC /bin/sh -c 'chmod u+x /var/go/.ansible/tmp/ansible-tmp-1562189970.7-142759633793038/ /var/go/.ansible/tmp/ansible-tmp-1562189970.7-142759633793038/AnsiballZ_molecule_vagrant.py && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /var/go/.ansible/tmp/ansible-tmp-1562189970.7-142759633793038/AnsiballZ_molecule_vagrant.py && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c 'rm -f -r /var/go/.ansible/tmp/ansible-tmp-1562189970.7-142759633793038/ > /dev/null 2>&1 && sleep 0'
    The full traceback is:
    WARNING: The below traceback may *not* be related to the actual failure.
      File "/tmp/ansible_molecule_vagrant_payload_VrLKoY/__main__.py", line 395, in up
        self._vagrant.up(provision=provision)
      File "/usr/local/lib/python2.7/dist-packages/vagrant/__init__.py", line 337, in up
        self._call_vagrant_command(args)
      File "/usr/local/lib/python2.7/dist-packages/vagrant/__init__.py", line 963, in _call_vagrant_command
        stderr=err_fh, env=self.env)
      File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
        raise CalledProcessError(retcode, cmd)

    failed: [localhost] (item={'box': u'ubuntu/xenial64', 'name': u'Ubuntu'}) => {
        "ansible_loop_var": "item",
        "changed": false,
        "invocation": {
            "module_args": {
                "config_options": {},
                "force_stop": false,
                "instance_interfaces": [],
                "instance_name": "Ubuntu",
                "instance_raw_config_args": null,
                "platform_box": "ubuntu/xenial64",
                "platform_box_url": null,
                "platform_box_version": null,
                "provider_cpus": 2,
                "provider_memory": 512,
                "provider_name": "virtualbox",
                "provider_options": {},
                "provider_override_args": null,
                "provider_raw_config_args": null,
                "provision": false,
                "state": "up"
            }
        },
        "item": {
            "box": "ubuntu/xenial64",
            "name": "Ubuntu"
        },
        "msg": "ERROR: See log file '/tmp/molecule/test-role-vagrant/default/vagrant-Ubuntu.err'"
    }

Content of sample error file identified in Molecule output:

### 2019-07-03 10:08:56 ###
### 2019-07-03 10:08:56 ###
A Vagrant environment or target machine is required to run this
command. Run `vagrant init` to create a new Vagrant environment. Or,
get an ID of a target machine from `vagrant global-status` to run
this command on. A final option is to change to a directory with a
Vagrantfile and to try again.

Note that with the same sample role and environment, rolling back to Molecule 2.20.1 via pip install molecule==2.20.1 fixed the problem and Vagrant boxes were again created successfully.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jonasjoestcommented, Jul 10, 2019

I have got the same Issue with vagrant driver. But instead I use the libvirt provider. (Provider doesn’t matter I think…)

It is very likely that the invokation of the vagrant command via “vagrant-molecule” has not been adapted to the new directory structure.

The vagrant command needs to be invoked where the Vagrantfile is located. With the introduction of the new directory structure this location changed from /tmp/molecule/[role name]/[scenario name] (1.20.1) to /tmp/mol.[user]/molecule/[role name]/[scenario name]/molecule/vagrant/[scenario name] (1.22rc3).

As far as I understand, the working directory for the vagrant call needs to be adapted to the correct path.

0reactions
decentral1secommented, Aug 3, 2019

@ssbarnea please see https://github.com/ansible/molecule/pull/2170#pullrequestreview-270474667. I think we should merge that fix and make a final release candidate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Molecule 2.22rc3: Vagrant driver regression #2150 - Ansible
Running Molecule test on a sample role with a Vagrant driver and a Virtualbox provider should result in a Virtualbox VM being brought...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found