Ansible failes to provision Vagrant VM

Following the documentation listed here https://roots.io/trellis/docs/local-development-setup/

When I reach step 4 and run vagrant up the provisioning step fails with the following messages output to the console

PLAY [WordPress Server: Install LEMP Stack with PHP 7.1 and MariaDB MySQL] *****
 [WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin
(<ansible.plugins.callback.vars.CallbackModule object at 0x103bfbcf8>): 'dict'
object has no attribute 'iteritems'


TASK [Gathering Facts] *********************************************************
 [WARNING]: Failure using method (v2_runner_on_ok) in callback plugin
(<ansible.plugins.callback.output.CallbackModule object at 0x102eabd68>): name
'unicode' is not defined


TASK [common : Load wordpress_sites.yml vars into <env>_sites vars] ************
 [WARNING]: Failure using method (v2_runner_item_on_skipped) in callback plugin
(<ansible.plugins.callback.output.CallbackModule object at 0x102eabd68>): name
'unicode' is not defined


TASK [common : Fail if there are duplicate site keys within host's wordpress_sites] ***

TASK [common : Validate wordpress_sites] ***************************************
 [WARNING]: Failure using method (v2_runner_on_skipped) in callback plugin
(<ansible.plugins.callback.output.CallbackModule object at 0x102eabd68>): name
'unicode' is not defined


TASK [common : Validate format of site_hosts] **********************************

TASK [common : Verify dict format for apt package component variables] *********
 [WARNING]: Failure using method (v2_runner_on_failed) in callback plugin
(<ansible.plugins.callback.output.CallbackModule object at 0x102eabd68>): name
'unicode' is not defined

Ansible version: 2.4.1.0
Vagrant Version 2.0.1

Are you perhaps running python 3? If so, could you try python 2.7.x?

Upstream Ansible is still preparing python 3 compatibility. Trellis will also have a few compatibility issues to sort out.

python -V is reporting Python 2.7.10

I couldn’t reproduce with python 2.7.10 with ansible 2.4.1.0. I also tried ansible 2.5.0a1 just in case.

I was able to reproduce with python 3.5.x (with ansible 2.4.1.0).

Is ansible executing from your local host machine or the guest vm?
vagrant provision output includes…

  • from host: Running provisioner: ansible...
  • from guest: Running provisioner: ansible_local...

You reported python 2.7.10, presumably for your local host machine. But any chance you are running ansible local and the guest vm uses python 3.x? You could check by running vagrant ssh then python -V.

If it turns out you’re using ansible local and the vm has python 3.x, that’s strange and maybe you’ve modified the vagrant box or its version?

If python 3.x on the vm is not the issue, I’d start reviewing your system setup on a more fundamental level, such as virtual environments (e.g., virtualenv or pyenv), or perhaps try a fresh install of python or ansible.

You could also test a fresh clone of Trellis with zero customizations at all (except run ansible-galaxy install ... and get a bedrock clone in place for site). If vagrant up works, that suggests there were issues with your customizations to the original project.

1 Like

Resolved this by uninstalling Python 3 from my local machine and re-installing ansible via pip install ansible.

1 Like

I also encountered this issue. The problem for me was that I installed ansible with homebrew instead of pip. When running head -1 $(which ansible-playbook) I saw that it was using python 3 even though my local python -V was 2. Reinstalling with pip fixed it.

1 Like