# Ansible deploy subtree failure on web/app/uploads directory

**URL:** https://discourse.roots.io/t/ansible-deploy-subtree-failure-on-web-app-uploads-directory/3986
**Category:** bedrock
**Tags:** deploys
**Created:** 2015-06-07T08:10:38Z
**Posts:** 12

## Post 1 by @10SexyApples — 2015-06-07T08:10:38Z

Having a wonderful time with all the hard work you guys have put in to ansible-bedrock and all the other projects that have emerged … with you since the get go … o.g. roots … so first things first THANKS GUYS!

And now to the issue at hand …

I got my vagrant up, then I got my provision on and all is wonderful in the land of little sleep, but, on deploy to my freshly-created, digital-ocean-ansible-provisioned, droplet I hit the snag mentioned here on this closed thread - [Symlink issues with deploys - #12 by treb0r](https://discourse.roots.io/t/symlink-issues-with-deploys/3670/12)

… not exactly the same but close enough …

I’ve checked that I had the latest files as mentioned there ( assumed I would since I only cloned them 48 hours ago ) and they are there …

```
$ ag subtree main.yml
4:project_subtree: "{{ project.subtree | default(false) }}"
```

```
$ ag subtree main.yml
18:- name: Move project subtree into root folder
19: shell: mv {{ deploy_helper.new_release_path }}/{{ project_subtree }}/* {{ deploy_helper.new_release_path }}
20: when: project_subtree != 'False'
```

Here is the fail:

```
TASK: [deploy | Create shared symlinks] *************************************** 
failed: [x.x.x.x] => (item={'path': 'web/app/uploads', 'src': 'uploads'}) => {"failed": true, "item": {"path": "web/app/uploads", "src": "uploads"}, "path": "/srv/www/mysite.com/releases/20150607034217/web/app/uploads", "state": "absent"}
msg: Error while linking: [Errno 2] No such file or directory

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/Users/me/deploy.retry

x.x.x.x : ok=11 changed=7 unreachable=0 failed=1
```

Any clue why it’s failing on this?

---

## Post 2 by @poggen — 2015-06-07T08:25:13Z

What does your directory structure look like? It if looks like this;

```
/
-ansible
-site
```

I think you’ll need to add `subtree: site` to your group\_vars/production and/or staging.

---

## Post 3 by @10SexyApples — 2015-06-07T17:04:11Z

Yes, my directory structure is as such … it’s set up exactly like the roots example project … I’ll give that a go

---

## Post 4 by @10SexyApples — 2015-06-07T20:01:43Z

Thanks Poggen that did it … I checked that file for comparison too before I ran the deploy and somehow missed that … ( someone needs thicker glasses … heh )

---

## Post 5 by @10SexyApples — 2015-06-15T03:30:07Z

I fear I might be losing my mind … previously when this got resolved I had checked my group\_vars/production against the one on the example project site and realized that the example project did in fact have the subtree: site in it and mine ( cloned from ansible repo ) did not, so, I added it and all was good.

Now I am on a new project with new files and I was having an issue that made me think that perhaps I needed to also set the site:subtree entry in my group\_vars/development, so I referred back to the example project to how it was done there again and lo and behold the subtree: site entry in group\_vars/production isn’t even there any more, but, there is no commit or file change notification to represent this change?

Very confused right now as to whether I need to continue using the site:subtree directive now as my directory structure is exactly like the Project Example and all traces of it are now gone from the files there … and also this entry in group\_vars seems to have vanished as well from the example so wondering if I should still be using it …

project\_pre\_build\_commands\_local:

- path: "{{ project.local\_path }}/web/app/themes/sage"  
cmd: npm install
- path: "{{ project.local\_path }}/web/app/themes/sage"  
cmd: bower install
- path: "{{ project.local\_path }}/web/app/themes/sage"  
cmd: gulp --production

project\_local\_files:

- name: compiled theme assets  
src: "{{ project.local\_path }}/web/app/themes/sage/dist"  
dest: web/app/themes/sage

I’m too green with all the new stuff I’m learning right now, so, trying to stay very vanilla and reliant on the example files so when they change without comment I’m a bit lost unfortunately.

Any help on this is most welcome~

---

## Post 6 by @poggen — 2015-06-15T07:16:08Z

@swalkinshaw explained the way `subtree` works in [another thread](https://discourse.roots.io/t/best-practice-for-trellis-with-multiple-sites/3981/3):

> [@Best practice for Trellis with multiple sites](https://discourse.roots.io/t/best-practice-for-trellis-with-multiple-sites/3981/3):
>
> `subtree` is only needed if the root of a Git repo is **not** “Bedrock” itself". (ie: your git repo starts with subfolders like `ansible` and `site`).

---

## Post 7 by @10SexyApples — 2015-06-15T07:35:38Z

That’s what I thought … and the project example is set up this way too … hence when you answered my initial question with this info I went to the project example and verified that the subtree: site directive was in fact in the example project’s group\_vars/production file … this is why I am so confused why it isn’t there now … am I crazy?

---

## Post 8 by @poggen — 2015-06-15T09:43:10Z

`subtree: site` [is still in the example repo](https://github.com/roots/roots-example-project.com/blob/master/ansible/group_vars/production#L30).

---

## Post 9 by @10SexyApples — 2015-06-15T23:27:08Z

Well that answers that then … I am crazy … that’s twice I’ve done that now … I actually said to myself "self, you know you missed this before … are you sure you’re not looking at the ansible repo instead of the example project repo … I seriously checked so many times and still managed to be comparing files in the wrong repo … heh … time to get some sleep for sure … and thanks for setting me straight again.

That answers the mysteriously missing project\_pre\_build question as well …

I do have one question remaining though … I noticed on the example project that they don’t have the subtree: site directive in the group\_vars/development file … isn’t this needed there as well? I have it in my development file and that is correct for my setup right? My setup being exactly the same as the example project~

---

## Post 10 by @10SexyApples — 2015-06-16T05:44:37Z

I removed subtree from my local dev group\_vars because I don’t think it has any relevance there … correct me if I’m wrong … otherwise, just consider this ancient history :wink:

---

## Post 11 by @swalkinshaw — 2015-06-16T16:34:36Z

`subtree` is only used for deployments so it can be left out whenever you aren’t deploying (like in `development` for example).

---

## Post 12 by @10SexyApples — 2015-06-16T20:47:07Z

Thank you for the confirmation @swalkinshaw :wink:
