Deploying to remote from Windows

In the Windows section of the docs, under “Running Ansible commands”, I’m told

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.

By default, Vagrant will share your project directory (the directory with the Vagrantfile) to /vagrant. – Vagrant docs

Feel free to post back if you don’t find the files in /vagrant

So they are! I guess they didn’t appear with my find command since they’re across an FS boundary. Thanks.

We’d love it if you were to PR the Trellis Windows docs to mention this /vagrant path. No obligation though.

I’m afraid I may not be knowledgeable enough. Is it always at /vagrant, or is that by default, or what?

New issue now:

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.

Any ideas?

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.

See if this thread addresses the issue: Running deploy within the guest VM on windows : Issue with building assets

If any new issues come up and you’re stuck, go ahead and start a new thread.

Thanks.

Added a pull request for the doc change at https://github.com/roots/docs/pull/29.

3 Likes

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.

1 Like