Roots Discourse

Problems with VM and ansible when running Vagrant Provision

Hi guys,

Am having some issues getting back to a working state with the dev VM for a project that was built last year with Sage/Trellis/Bedrock.

In summary, since then I upgraded my laptop and pulled the files from the old machine over to the new one. When trying to run up the VM for this project to update plugins/wordpress, I found I couldn’t access the site. The site was originally set up with the domain using a .dev extension locally… so I’ve walked through the instructions on changing to a .test. i.e. these ones: Updating Development from .dev to .test TLD

When running Vagrant provision this happened:

Michaels-MBP-13:trellis michaelmcmahon$ vagrant provision

**==> default: Running provisioner: ansible...**

Vagrant gathered an unknown Ansible version:

and falls back on the compatibility mode '1.8'.

Alternatively, the compatibility mode can be specified in your Vagrantfile:

https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

default: Running ansible-galaxy...

Traceback (most recent call last):

File "/usr/local/bin/ansible-galaxy", line 43, in <module>

import ansible.constants as C

ImportError: No module named ansible.constants

Ansible failed to complete successfully. Any error output should be

visible above. Please fix these errors and try again.

Subsequently I have spent some time trying to figure out what the issue is. I’ve checked the version of Ansible… it’s 2.6.4

Have looked through the error logs on the VM and don’t see any errors.

Current status is that Vagrant Up no longer works. This is what I see…

Michaels-MBP-13:majacmedical.com.au michaelmcmahon$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...

**==> default: Box 'base' could not be found. Attempting to find and install...**

default: Box Provider: virtualbox

default: Box Version: >= 0

**==> default: Box file was not detected as metadata. Adding it directly...**

**==> default: Adding box 'base' (v0) for provider: virtualbox**

default: Downloading: base

An error occurred while downloading the remote file. The error

message, if any, is reproduced below. Please fix this error and try

again.

Couldn't open file /Users/michaelmcmahon/Sites/majacmedical.com.au/base

Any suggestions?

Have you been able to start a fresh new Trellis install / Vagrant machine, to confirm it’s not something else on your computer that’s the problem?

Not as yet. Am now searching for documentation on how to do that…

I guess I would want to do this with the same version of Trellis/Sage/Bedrock that I’m using on this theme right? Otherwise the issue could be in the difference between the old and current versions?

If your project’s Trellis version is a year old, you’ll probably need to roll back your Ansible version to be compatible.

Options to find the Ansible version appropriate for your Trellis project:

  • Check your project’s CHANGELOG.md for the most recently mentioned Ansible version
  • Older Trellis: roles/common/defaults/main.yml
  • More recent Trellis: lib/trellis/plugins/vars/version.py

Notes on installing older Ansible versions (see entire thread)

Somewhat related discussion for compatibility between Ansible versions and Trellis


When I google errors such as Adding box 'base' (v0) for provider: virtualbox** and Couldn't open file /**/base, I see suggestions that you have created your own Vagrantfile instead of just using the one included with Trellis. This could happen if you vagrant init somewhere, or perhaps if you vagrant up from a directory other than your Trellis project.

1 Like

Thanks Phil.

Very helpful. Looks like I needed Ansible 2.5.3 so I’ve rolled back to that.

Am running Vagrant Up right now and it looks like it’s setting up the dev machine (I guess that’s being done from scratch because of the change to the .test TLD)…

I don’t think the VagrantFile had been changed. So fingers crossed this will get things rolling again.

Okay, turns out the Vagrant Up was running in my dummy project.

Back to the main project, still getting this error about “No module named six”. From reading in this forum, this seems to be related to Ansible version. Do you think I need to go back below 2.5.3?

Michaels-MBP-13:trellis michaelmcmahon$ vagrant provision

**==> default: Running provisioner: ansible...**

Vagrant has automatically selected the compatibility mode '2.0'

according to the Ansible version installed (2.5.3).

Alternatively, the compatibility mode can be specified in your Vagrantfile:

https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

default: Running ansible-galaxy...

- changing role composer from 1.5.0 to 1.5.0

- downloading role 'composer', owned by geerlingguy

- downloading role from https://github.com/geerlingguy/ansible-role-composer/archive/1.5.0.tar.gz

- extracting composer to /Users/michaelmcmahon/Sites/majacmedical.com.au/trellis/vendor/roles/composer

- composer (1.5.0) was installed successfully

- changing role ntp from 1.3.0 to 1.3.0

- downloading role 'ntp', owned by geerlingguy

- downloading role from https://github.com/geerlingguy/ansible-role-ntp/archive/1.3.0.tar.gz

- extracting ntp to /Users/michaelmcmahon/Sites/majacmedical.com.au/trellis/vendor/roles/ntp

- ntp (1.3.0) was installed successfully

- changing role logrotate from e7a498d to e7a498d

- downloading role 'logrotate', owned by nickhammond

- downloading role from https://github.com/nickhammond/ansible-logrotate/archive/e7a498d.tar.gz

- extracting logrotate to /Users/michaelmcmahon/Sites/majacmedical.com.au/trellis/vendor/roles/logrotate

- logrotate (e7a498d) was installed successfully

- changing role swapfile from 0.4 to 0.4

- downloading role 'swapfile', owned by kamaln7

- downloading role from https://github.com/kamaln7/ansible-swapfile/archive/0.4.tar.gz

- extracting swapfile to /Users/michaelmcmahon/Sites/majacmedical.com.au/trellis/vendor/roles/swapfile

- swapfile (0.4) was installed successfully

- changing role geerlingguy.daemonize from 1.1.1 to 1.1.1

- downloading role 'daemonize', owned by geerlingguy

- downloading role from https://github.com/geerlingguy/ansible-role-daemonize/archive/1.1.1.tar.gz

- extracting geerlingguy.daemonize to /Users/michaelmcmahon/Sites/majacmedical.com.au/trellis/vendor/roles/geerlingguy.daemonize

- geerlingguy.daemonize (1.1.1) was installed successfully

- changing role mailhog from 2.1.0 to 2.1.0

- downloading role 'mailhog', owned by geerlingguy

- downloading role from https://github.com/geerlingguy/ansible-role-mailhog/archive/2.1.0.tar.gz

- extracting mailhog to /Users/michaelmcmahon/Sites/majacmedical.com.au/trellis/vendor/roles/mailhog

- mailhog (2.1.0) was installed successfully

 **[WARNING]: - dependency geerlingguy.daemonize from role mailhog differs from**

**already installed version (1.1.1), skipping**

default: Running ansible-playbook...

ERROR! Unexpected Exception, this is probably a bug: No module named six

to see the full traceback, use -vvv

Ansible failed to complete successfully. Any error output should be

visible above. Please fix these errors and try again.

If I try to “pip install six” it seems it’s there already.

Michaels-MBP-13:trellis michaelmcmahon$ pip install six
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (1.4.1)
Michaels-MBP-13:trellis michaelmcmahon$ python --version
Python 2.7.10
Michaels-MBP-13:trellis michaelmcmahon$ ansible --version
ansible 2.5.3
  config file = /Users/michaelmcmahon/Sites/majacmedical.com.au/trellis/ansible.cfg
  configured module search path = [u'/Users/michaelmcmahon/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Python/2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.10 (default, Oct  6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]

Should I try a Vagrant destroy and then Vagrant Up (saw something in this post about that).

We do a lot of Ansible and Python troubleshooting over here even though it’s not really the appropriate place for it. Please look at existing threads on this forum along with other places, such as Stack Overflow, to try and figure out how to fix your environment issues.