This is an issue we’ve been experiencing ever since trying to deploy Trellis from Windows computers. I’ve tried replicating the issue from my own computer (OSX) and it is exactly the same.
Since ansible doesn’t run on Windows the appropriate workflow to deploy from windows machine is to ssh into the local vagrant box (with ssh vagrant) and move to the trellis directory (~/trellis) then run the commands from there.
I’ve tried running the commands from both ~/trellis and /vagrant but I always get the ./bin/deploy.sh: line 45: ansible-playbook: command not found.
Everything works as expected if I deploy the site from OSX with ansible installed rather than connecting to the host machine and trying to deploy from there.
Is your vagrant box provisioned? I don’t know how you could SSH in without it being provisioned since it happens on the first vagrant up, unless there was an error.
@kalenjohnson it seems to me that Ansible just isn’t installed on the VM.
@zigav can you try backing up your database and doing (whatever the Windows equivalent of) vagrant destroy && vagrant up to see if it just went wrong the first time?
I can SSH to my server from command prompt but I cannot run ./bin/deploy.sh due to it not being available on windows.
If I vagrant SSH to run the command then the script does run but in the end I am presented with a SSH Error: data could not be sent to remote host - UNREACHABLE! message.
I’ll try again but I have no idea where to start at the moment. My best guess is that my local windows .id_rsa.pub isn’t being sent by vagrant? Maybe vagrant sends it’s own key files with this method?
I wonder if there is an easy way to deploy directly if I ssh to the remote server?
I have indeed. I am using the Git shell that comes with Git for Windows so ssh-agent should be automatically launched, according to the article that is linked in the docs.
I have tried this with putty too and enabled agent forwarding. Same result.
UPDATE: Still not working and I have tried the following:
https://github.com/hashicorp/vagrant/issues/1735#issuecomment-25640783 (this one seems like it would have to be customised for trellis? I have already updated ‘github_rsa’ to ‘id_rsa’ because that is the name of the key files generated by the git for windows installer. The folders might need updating too?)
If anybody has any ideas they would be much appreciated. For the moment I have to get my Mac developer to deploy the code.
I can actually SSH to the remote server from within the vagrant box, so SSH keys are clearly being sent by vagrant.
I had a theory that the ‘root’ username was not being passed to the server when issuing the deploy command from the vagrant box. Perhaps I need to configure something differently?
If I update my hosts/staging file to the following:
I have managed to set it up as described and I can now run the ansible deploy command directly from the WLS prompt without ssh’ing to vagrant: ./bin/deploy.sh staging website.ie
But now I have a new errors:
[WARNING] Ansible is being run in a world writable directory (/mnt/c/dev/example.com/trellis), ignoring it as an ansible.cfg source. For more information see https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [Ensure necessary variables are defined] ***********************************************************************************************************************************************************
TASK [Ensure environment is defined] ********************************************************************************************************************************************************************
skipping: [localhost]
[WARNING]: Could not match supplied host pattern, ignoring: web
[WARNING]: Could not match supplied host pattern, ignoring: staging
PLAY [Test Connection] **********************************************************************************************************************************************************************************
skipping: no hosts matched
PLAY [Deploy WP site] ***********************************************************************************************************************************************************************************
skipping: no hosts matched
PLAY RECAP **********************************************************************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=0
The error is telling you what’s wrong: ansible is being run from a world-writeable directory. This is because WSL’s default strategy for handling the conversion from Windows permissions to Linux permissions is to just make everything writeable by everyone (not really ideal). The link in the error should get you on the path to fixing it: https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir You’ll need to enable ‘metadata’ on the mount where your project is, and then give it some more reasonable permissions.