Trellis error - local machine - ansible-playbook dev.yml

I am getting an error when trying to use the ansible-playbook dev.yml command to provision my local dev server instead of vagrant provision as suggested in the comments of the file trellis/hosts/development. I’ve never had problems with this command before, any ideas? thank you

➜ trellis git:(master) ✗ ansible-playbook dev.yml -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory -vvvv
Using /home/sie/Sites/wbba-trellis/trellis/ansible.cfg as config file
Loaded callback output of type stdout, v2.0

PLAYBOOK: dev.yml **************************************************************
1 plays in dev.yml

PLAY [WordPress Server: Install LEMP Stack with PHP 7.0 and MariaDB MySQL] *****

TASK [setup] *******************************************************************
File lookup using /home/sie/.ssh/digital_ocean.pub as file
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: vagrant
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o Port=2222 -o ‘IdentityFile="/home/sie/Sites/wbba-trellis/trellis/.vagrant/machines/default/virtualbox/private_key"’ -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/home/sie/.ansible/cp/ansible-ssh-%h-%p-%r 127.0.0.1 ‘/bin/sh -c ‘"’"’( umask 77 && mkdir -p “echo $HOME/.ansible/tmp/ansible-tmp-1479079414.4-97647499373080” && echo ansible-tmp-1479079414.4-97647499373080="echo $HOME/.ansible/tmp/ansible-tmp-1479079414.4-97647499373080" ) && sleep 0’"’"’'
System info:
Ansible 2.1.1.0; Linux
Trellis at “WP 4.6 Compat: set WP_HOME/SITEURL directly”

Failed to connect to the host via ssh.
fatal: [default]: UNREACHABLE! => {“changed”: false, “unreachable”: true}
[WARNING]: Could not create retry file ‘dev.retry’. [Errno 2] No such file or
directory: ‘’

PLAY RECAP *********************************************************************
default : ok=0 changed=0 unreachable=1 failed=0

➜ trellis git:(master) ✗

vagrant provision works ok, but I need to use --tags and --skip-tags

I see that the connection is attempted on Port=2222. The vagrant_ansible_inventory probably has an entry ansible_ssh_port=2222.

Could you check that this is the same port listed when you run vagrant ssh-config? If this latter command shows something else, e.g., port 2200, that could indicate that Vagrant fixed a port collision by changing the ssh port for this VM. It may have happened because some other vagrant VM was already running and using 2222. The port in the current VM’s vagrant_ansible_inventory won’t automatically update unless you vagrant provision.

So, if the port is different in vagrant ssh-config, you could edit the vagrant_ansible_inventory port to match, or just run vagrant provision to get vagrant to update the vagrant_ansible_inventory with the latest info for the vm.

If it’s not already a habit, you might run vagrant global-status every once in a while to make sure there aren’t old VMs running unnecessarily.

thanks for your reply,

here’s the content of the file .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory

Generated by Vagrant

default ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 ansible_ssh_user=‘vagrant’ ansible_ssh_private_key_file=’/home/sie/Sites/wbba-trellis/trellis/.vagrant/machines/default/virtualbox/private_key’

[web]
default

[development]
default

the port is 2222 in ssh config

➜ trellis git:(master) ✗ vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/sie/Sites/wbba-trellis/trellis/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes

i destroyed the vagrant box and ran vagrant up --provision, then vagrant global-status returns:

➜ trellis git:(master) ✗ vagrant global-status
id name provider state directory

d8b91d6 default virtualbox running /home/sie/Sites/wbba-trellis/trellis

The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date. To interact with any of the machines, you can go to
that directory and run Vagrant, or you can use the ID directly
with Vagrant commands from any directory. For example:
“vagrant destroy 1a2b3c4d”

i added a ssh key with ssh-keygen (id_rsa), then ran the ansible command again:

➜ trellis git:(master) ✗ ansible-playbook dev.yml -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory -vvvv
Using /home/sie/Sites/wbba-trellis/trellis/ansible.cfg as config file
Loaded callback output of type stdout, v2.0

PLAYBOOK: dev.yml **************************************************************
1 plays in dev.yml

PLAY [WordPress Server: Install LEMP Stack with PHP 7.0 and MariaDB MySQL] *****

TASK [setup] *******************************************************************
File lookup using /home/sie/.ssh/digital_ocean.pub as file
File lookup using /home/sie/.ssh/id_rsa.pub as file
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: vagrant
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o Port=2222 -o ‘IdentityFile="/home/sie/Sites/wbba-trellis/trellis/.vagrant/machines/default/virtualbox/private_key"’ -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/home/sie/.ansible/cp/ansible-ssh-%h-%p-%r 127.0.0.1 ‘/bin/sh -c ‘"’"’( umask 77 && mkdir -p “echo $HOME/.ansible/tmp/ansible-tmp-1479163978.77-6731877388667” && echo ansible-tmp-1479163978.77-6731877388667="echo $HOME/.ansible/tmp/ansible-tmp-1479163978.77-6731877388667" ) && sleep 0’"’"’'
System info:
Ansible 2.1.1.0; Linux
Trellis at “WP 4.6 Compat: set WP_HOME/SITEURL directly”

Failed to connect to the host via ssh.
fatal: [default]: UNREACHABLE! => {“changed”: false, “unreachable”: true}
[WARNING]: Could not create retry file ‘dev.retry’. [Errno 2] No such file or
directory: ‘’

PLAY RECAP *********************************************************************
default : ok=0 changed=0 unreachable=1 failed=0

I don’t why it isn’t working. I can’t pick out any causes in the info posted above. The command connects successfully for me (Vagrant 1.8.7, Ansible 2.2.0.0, OS X).

It’s not as convenient, but you could specify options in your Vagrantfile then use vagrant provision.

# Vagrantfile
     ...
     config.vm.provision :ansible do |ansible|
+      ansible.verbose = 'vvvv'
+      ansible.tags = ['nginx','wordpress']
+      ansible.skip_tags = ['diffie-hellman']
       ansible.playbook = File.join(ANSIBLE_PATH, 'dev.yml')
       ...