# Deploying to Staging on DigitalOcean with Ansible

**URL:** https://discourse.roots.io/t/deploying-to-staging-on-digitalocean-with-ansible/3138
**Category:** trellis
**Created:** 2015-03-07T07:01:24Z
**Posts:** 8

## Post 1 by @romero2k — 2015-03-07T07:01:24Z

I’ve been doing development locally with bedrock-ansible, which is working very well for me. I’ve started playing with DigitalOcean droplets for staging and possibly production environments for finished work. Now I’ve read the readme for the bedrock-ansible project and if I understand it correctly, I should be able to spin up a new droplet on DO (I do that manually) running Ubuntu 14.04. Then I would `apt-get install ansible` to get ansible running on the server. Where I go from here is where I get hazy. At this point, would I just have to edit the group\_vars/staging and hosts/staging file to point at my droplet’s IP and hostname and set the variables and then just run `ansible-playbook -i hosts/staging site.yml`. Is that it? I feel like I’m missing something. Maybe I’m just not understanding the directions. Once I do this and setup the Capistrano stuff, I would be all set to use Capistrano to push the work from my dev install locally to the staging one? Sorry if these questions seem basic, but I’m trying to wrap my head around how to do this stuff in the easiest ways possible.

---

## Post 2 by @swalkinshaw — 2015-03-07T16:53:18Z

You got most of it correct.

But you don’t need to install Ansible on any remote servers. It’s always run from your local machine.

General process is outlined here: [https://github.com/roots/bedrock-ansible#stagingproductionremote-servers](https://github.com/roots/bedrock-ansible#stagingproductionremote-servers).

Then you run Capistrano run your local/dev machine as well. Like Ansible it just runs SSH commands onto your remote servers.

---

## Post 3 by @romero2k — 2015-03-14T04:54:09Z

OK, time for an alternate path, I think. The issue is that my main dev machine is a Windows box. The local development works fine; I was able to use the script that was suggested on the b-a github page to get everything working fine within Windows. However, when I do a `vagrant ssh` into the Vagrant VM and try to run ansible to push to my staging environment, it fails because every file is marked as executable, and Ansible does not like this. I tried a chmod -x on the scripts, but because it’s linked to a Windows folder outside the VM, it can’t. I don’t know if there’s anything else I could try.

---

## Post 4 by @fullyint — 2015-03-14T15:33:05Z

@romero2k I’m not running windows, so I’m kinda guessing here.

**Running Ansible within Vagrant VM.** I wonder if it would help (and not break stuff?) to adjust the `mount_options` to `["dmode=775,fmode=664"]` (for `config.vm.synced_folder` in `Vagrantfile`) as [described here](http://stackoverflow.com/a/22024313). This would mark synced files as not executable. Let us know if this works, because maybe these options should replace the `['dmode=776', 'fmode=775']` that `bedrock-ansible` has used from its beginning (?).

Or, maybe switch the vagrant sync folder to use [rsync](http://docs.vagrantup.com/v2/synced-folders/rsync.html), with `rsync__args` [like these](https://github.com/roots/bedrock-ansible/issues/8#issuecomment-51958685) to mark synced files as not executable.

**Running Ansible within remote staging server.** I’ve never tried your original approach of installing ansible on a DigitalOcean droplet and running the playbook with a local [`ansible_connection`](http://docs.ansible.com/intro_inventory.html#list-of-behavioral-inventory-parameters) (vs. ssh connection to a remote), but it seems it could work. The steps you described sounded right. If you run into trouble, you could check out concepts at [Running ansible playbook in localhost](http://ansible.pickle.io/post/86598332429/running-ansible-playbook-in-localhost) and in the [shell script](https://gist.github.com/starise/e90d981b5f9e1e39f632/a4b7819b3663c5d34e7c8a2ce4556b50771073e8) you probably used in your Vagrant VM.

---

## Post 5 by @romero2k — 2015-03-16T08:11:31Z

Unfortunately, changing the mount options did not work for me. And Windows doesn’t have an rsync executable and it looks like they only make one that works with MinGW. I guess I will have to be content with using b-a for local development and having to do some legwork to get it done on the server side for staging/production.

---

## Post 6 by @mauro — 2015-05-12T21:28:50Z

Hi @romero2k I was wondering if you ran into directory length problems on your vagrant/ansible install.

It would be very helpfull if you could briefly describe the steps that you took to setup your local dev machine.

For deployment I don’t use ansible so that would not be a problem.

This is the problem that I’m running into:

> [@Error on vagrant up - Windows 8.1](https://discourse.roots.io/t/error-on-vagrant-up-windows-8-1/3759/8):
>
> Thanks that worked. Now I’m running into the directory length problem with npm: OSError: [Errno 2] No such file or directory: '/srv/www/roots.dev/current/web/app/themes/sage/node\_modules/asset-builder/node\_modules/main-bower-files/node\_modules/vinyl-fs/node\_modules/glob-stream/node\_modules/unique-stream/node\_modules/es6-set/node\_modules/es5-ext/node\_modules/es6-symbol/test/is-native-implemented.js' The file it’t there, however it seems that Ansible (Vagrant?) is not able to go beyond the 260 c…

Thanks

---

## Post 7 by @andylbrummer — 2015-08-09T17:12:56Z

I was able to add

```
config.vm.synced_folder ".", "/vagrant", mount_options: ['dmode=776', 'fmode=664']
```

in the if Vagrant::Util::Platform.windows? block and that worked for me.

---

## Post 8 by @romero2k — 2015-08-19T20:19:08Z

That didn’t change anything for me. I’ve just had to settle on this not working for me.
