To run the ansible-playbook commands to provision remote servers, you’ll need to SSH in to the VM, cd to the directory with your trellis files, then run the setup and deployment commands.
But what directory with the trellis files? As far as I can tell they don’t appear anywhere in the VM’s storage.
I’m getting ./deploy.sh: /bin/bash^M: bad interpreter: No such file or directory. None of the files which mention /bin/bash have DOS line endings so I don’t know where that’s coming from.
On another host machine, this one Linux, doing the same within the VM is fine.
I spoke too soon regarding the DOS line endings. On the VM within Windows they do have DOS endings. Probably a git configuration thing. Should be fine, I’ll report back…
Okay, fixing the line endings did the trick. Likely wouldn’t have been an issue if I’d have had the git line endings configuration set to keep them the same as the source repo.
The deploy command now runs, but it fails when it gets to the npm install command I’ve uncommented in deploy-hooks/build-before.yml. I have this (I forget if I edited it from stock):
---
- name: Run npm install
command: npm install
connection: local
args:
chdir: "{{ project.local_path }}/web/app/themes/ceso2016"
It fails with this:
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1459218288.52-251521563006084/command", line 2409, in <module>
main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1459218288.52-251521563006084/command", line 187, in main
os.chdir(chdir)
OSError: [Errno 2] No such file or directory: '/site/web/app/themes/ceso2016'
fatal: [staging.ceso-saco.com]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "command"}, "parsed": false}
It’s right that /site/web/app/... doesn’t exist. I’d guess that it’s trying to find it relatively from the trellis directory, which is /vagrant, i.e. trying to build a path from /vagrant/../site/web/app/themes/ceso2016, which doesn’t exist of course because the trellis and site directories are in totally different places – could this be right? Any idea of a workaround?
Trellis doesn’t adjust the Vagrant default mentioned above, so unless you adjust share folders in the Vagrantfile or move your Vagrantfile, I think you’ll always find Trellis files on the VM at /vagrant.
What did you do to fix your line endings? I have a trellis based project (running on macOS) and I’m trying to share with a developer on Windows and we’re getting an unexpected exception complaining about “odd-length string” and I think it’s something to do with line-endings.