# Provisioning a new digital ocean droplet

**URL:** https://discourse.roots.io/t/provisioning-a-new-digital-ocean-droplet/7871
**Category:** trellis
**Created:** 2016-10-11T15:47:28Z
**Posts:** 16

## Post 1 by @andrew40 — 2016-10-11T15:47:28Z

Ok I’m a noobie I admit it…

Been using wordpress for years on about 50 sites i own and run. I have had a look and i’m converted. Fantastic way to do stuff with wordpress… well done all at Roots - must buy you a beer sometime, if you like chatting to an oldie!

Have it all setup locally and working perfectly.

Confused at the provisioning stage. i have it all sync’d with git on bitbucket. so i know how the deploy works with the pull from git onto the new remote DO server.

What I am unsure about chaps, is the setting up the DO server. I have a base ubuntu 16.04 setup and locked down with SSH access. What in gods name do i do now?

Do i just run ansible-playbook server.yml -e env= on my local server?

After setting up all my production values in the ‘local’ production.yml?

If thats the case i’m assuming it just connects to the remote server under ssh and installs the necessary files in the right places, which is of course excellent! My confusion arises due to the necessity to install Trellis and then the bedrock site would run in a vagrant environment on the new server. I would have thought vagrant was not needed on a new server and would create an unneeded server overhead.

I do see that you can just deploy bedrock with all the necessary, but then again that suggests we need to install composer - now is that locally or again on the server.

Thanks once again and I apologise if this is all beneath the majority of you but at least let an old chap have some fun!!

---

## Post 2 by @kalenjohnson — 2016-10-11T16:14:17Z

You are on the right track. When you first `vagrant up`, Ansible installs a bunch of stuff on the box for you. Provisioning a Digital Ocean droplet or another VM is the same thing. The droplet/VM is Ubuntu 16.04, just like the Vagrant box is. Vagrant is just using Virtualbox to create a virtual private server on your local computer, Digital Ocean is using similar technology to give you a box with your desired specs.

So yes… run the ansible playbook script, deploy, and if you follow the rest of the docs you should have your site live on the internet pretty quickly

---

## Post 3 by @andrew40 — 2016-10-11T16:45:04Z

Many thanks for your reply.

So I’m running ansible playbook script on my local osx terminal or within the trellis vagrant on my local osx. silly question I know but I’m assuming the latter but just wanting to make sure.

---

## Post 4 by @kalenjohnson — 2016-10-11T17:40:46Z

You run it from your OS X terminal, Ansible is not installed on the Vagrant box (unless your’e using Windows).

---

## Post 5 by @andrew40 — 2016-10-11T21:38:04Z

Ok, it seems to have gone well - but I had one failure which is listed below. what have I missed? I have masked usernames and Ip address for obv reasons.

"The conditional check ‘site\_uses\_local\_db and item.value.db\_create |  
default(True)’ failed. The error was: error while evaluating conditional  
(site\_uses\_local\_db and item.value.db\_create | default(True)): {{  
site\_env.db\_host == ‘localhost’ }}: {{ wordpress\_env\_defaults |  
combine(item.value.env | default({}), vault\_wordpress\_sites[item.key].env)  
}}: ‘dict object’ has no attribute u’[xxx.xx.xx.xxx](http://xxx.xx.xx.xxx)’

The error appears to have been in ‘/Users/username/Sites/CGW/trellis/roles  
/wordpress-setup/tasks/database.yml’: line 2, column 3, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

* * *

- name: Create database of sites  
^ here

fatal: [[xxx.xx.xx.xxx](http://xxx.xx.xx.xxx)]: FAILED! =\> {“failed”: true}"

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[xxx.xx.xx.xxx](http://xxx.xx.xx.xxx) : ok=89 changed=67 unreachable=0 failed=1  
localhost : ok=0 changed=0 unreachable=0 failed=0

---

## Post 6 by @40Q — 2016-10-11T22:19:56Z

@andrew40, Have you replaced [example.com](http://example.com) with your dev url inside development/vault.yml?

---

## Post 7 by @MWDelaney — 2016-10-11T23:39:14Z

I’ve been deploying Trellis sites for months now and I still miss this most of the time.

@andrew40 also don’t forget that you’ll need to manually import/upload your `uploads` and database after deploying. Here’s a quick rundown:

1. ssh to your Vagrant box and export your database:  
`$ cd trellis && vagrant ssh`

2. change directories to your web root on the Vagrant box and export your db to a dumpfile:  
`$ cd /srv/www/yourdomain.com/current/`  
`$ wp db export`

3. exit the ssh session (type `exit`) and find the database dump file in your Trellis directory named something like `yourdomain_com_development.sql`. Upload the dump file to your DO droplet in `/srv/www/yourdomain.com/current`. I usually just use an (S)FTP client for this. Also while you’re there copy your `uploads` directory from `site/web/app/` to `/srv/www/yourdomain.com/shared/`

4. ssh to your DO droplet, change directories to your web root:  
`$ ssh web@yourdomain.com`  
`$ cd /srv/www/yourdomain.com/current`

5. Trellis automatically sets up WordPress in when you deploy, but doesn’t set up your database, so reset the database and import your dumpfile:  
`$ wp db reset`  
`$ wp db import yourdomain_com_development.sql`

6. Search and replace your development URL with your production URL:  
`$wp search-replace yourdomain.dev yourdomain.com`

And that’s it! Now your site is deployed and its database and uploads are copied. Remember, too, that Trellis doesn’t maintain your database or uploads in version control, so you might want to spend the extra buck or two to enable DO backups, or find some other periodic backup plan for those assets.

I hope this is helpful!

---

## Post 8 by @andrew40 — 2016-10-12T00:01:49Z

Yes I gathered i would have to export/import the db but this was not a deploy.

All I’m running is “ansible-playbook server.yml -e env=staging” to provision a remote server.

I haven’t run deploy yet. The error comes at the ‘Create database of sites’

---

## Post 9 by @andrew40 — 2016-10-12T00:03:44Z

yes I’ve replaced it with the ip of the DO droplet.

---

## Post 10 by @MWDelaney — 2016-10-12T00:13:54Z

`example.com` in every `vault.yml` (development, staging, and production) needs to match how you edited `wordpress_sites.yml`.

So if you replaced `example.com` in `wordpress_sites.yml` with `yourdomain.com`, you’ll need make `vault.yml` match.

There are separate `wordpress_sites.yml` and `vault.yml` files for development, staging, and production and whatever you replaced [example.com](http://example.com) with should match in all of those places.

---

## Post 11 by @andrew40 — 2016-10-12T00:26:13Z

Yes they do, I have replaced all [example.com](http://example.com) with the ip address of the DO droplet, in both vault.yml and wordpress\_sites.yml for both staging and production. In development its a local domain i.e. standard example.dev.

In all instances the vault.yml and wordpress\_sites.yml match

Hope this helps…

---

## Post 12 by @MWDelaney — 2016-10-12T00:30:56Z

I’ve always done this with a domain name. I’m not sure if it’ll work with an IP address. Hopefully a Roots team member can weigh in here.

---

## Post 13 by @andrew40 — 2016-10-12T00:34:57Z

Here’s hoping but have seen another similar error posted on here recently which seems related to the latest Ansible.

I am pretty sure I am doing something wrong though! :slight_smile:

---

## Post 14 by @fullyint — 2016-10-12T01:50:55Z

I agree with @40Q and @MWDelaney that this bit of the error message …

```
vault_wordpress_sites[item.key].env) }}: 'dict object' has no attribute u'xxx.xx.xx.xxx'
```

… is an indication that [this line](https://github.com/roots/trellis/blob/df376a0aec8aa273c85ea8dd3c8ac807bf4b0f3a/group_vars/staging/vault.yml#L13) in `group_vars/staging/vault.yml` doesn’t match [this line](https://github.com/roots/trellis/blob/df376a0aec8aa273c85ea8dd3c8ac807bf4b0f3a/group_vars/staging/wordpress_sites.yml#L6) in `group_vars/staging/wordpress_sites.yml`. Could you confirm that those exact lines match in your `group_vars/staging` files?

Although you can make those two lines IP addresses, I believe you’ll make your life easier if you make those lines some sort of recognizable name for the site because the name is used in file paths and logs created on the server. A name would be more identifiable and the IP address may be a little more likely to change than a name. Most people use the domain name (recommended) but you could just use `cgw`, like this:

```
# group_vars/staging/wordpress_sites.yml
wordpress_sites:
  cgw:
    site_hosts:
      - canonical: staging.cgw.com
    etc.
```

```
# group_vars/staging/vault.yml
vault_wordpress_sites:
  cgw:
    env:
      db_password: example_dbpassword
      etc.
```

* * *

> [@andrew40](#):
>
> have seen another similar error posted on here recently which seems related

Aside from occurring on the same task, [the other error](https://discourse.roots.io/t/server-yml-failing-at-wordpress-setup-create-database-of-sites-after-upgrade-to-0-9-8/7861) is not related. The other error message mentioned a `template error`, which was the root of the problem, but your error does not.

* * *

Do you have the [same IP address](https://discourse.roots.io/t/production-server-provision-configures-staging-envs-if-hosts-are-the-same-bug-or-intention/6090) in `hosts/production` as you do in `hosts/staging`? If so there is a slight chance this could be the cause of the error you see (but I doubt it).

It is not recommended to put the staging and production sites on the same server, so the IP should differ between `hosts/production` and `hosts/staging`.

---

## Post 15 by @andrew40 — 2016-10-12T07:45:31Z

Thanks for that. I was basically just taking a good look at Trellis and trying to get me through a complete process so that I could then start using it with fervour. Hence why I didn’t have a FQDN.

Here are my associated files:

> _# group\_vars/staging/wordpress\_sites.yml_  
> wordpress\_sites:  
> 178.62.50.116:  
> site\_hosts:  
> - canonical: 178.62.50.116  
> # redirects:  
> # - [otherdomain.com](http://otherdomain.com)

> _# group\_vars/staging/vault.yml_  
> vault\_wordpress\_sites:  
> 178.62.50.116:  
> env:  
> db\_password: xxxxxxxxx  
> etc.

I will assign a staging FQDN domain today and give it a re-run to confirm my errors…

> [@fullyint](#):
>
> Do you have the same IP address in hosts/production as you do in hosts/staging? If so there is a slight chance this could be the cause of the error you see (but I doubt it).

Yes I do - I will change this today and spin up a new server.

---

## Post 16 by @andrew40 — 2016-10-12T09:29:51Z

I have actually just rewritten the files as before and provisioned the same server - ( I am assuming you can do that over a failed install) and it seems to have gone straight through with no issues.

I am assuming from that there might have been a space somewhere or something on the config files but all seems good.

I am also assuming that the 404 error not found page on Nginx at the address is because I have not deployed yet, because i would have expected to see the wordpress installation page?
