Unable to use mount point for uploads with project_shared_children

Hi,

Hoping you can help me with an issue. I’m an Ansible newbie, and have recently jumped in at the Trellis end.

I am provisioning and deploying to a VM on Google Cloud, and that’s working well (thank you for previous assistance). I have also set up a Google SQL instance to host the database separately and, with the help of your docs, got that working too.

However, I’m now trying to get our uploads directory onto a persistent disk attached to the VM, and am having difficulties.

I have a mount point for the disk at /mnt/disks/asc-uploads/. I moved all our images into that, so that they’re now sitting within /mnt/disks/asc-uploads/uploads/2017/. I have changed the ownership on all directories to web, with group www-data.

My group-vars/staging/main.yml now looks like this:

mysql_root_password: "{{ vault_mysql_root_password }}" # Define this variable in group_vars/staging/vault.yml

# Get the uploads link to point to our images stored in the persistent disk.
project_shared_children:
  - path: web/app/uploads
    src: /mnt/disks/asc-uploads/uploads

But of course (and I guess the “children” part should have been a clue) “src” is actually meant to be a relative rather than an absolute path, so that after deployment I end up with this:

mclarke@asc-staging:/srv/www/australiascience.tv/current$ ls -l web/app/
total 16
drwxr-xr-x 2 web www-data 4096 Oct 27 05:41 mu-plugins
drwxr-xr-x 7 web www-data 4096 Nov  2 00:45 plugins
drwxr-xr-x 3 web www-data 4096 Oct 27 05:41 themes
lrwxrwxrwx 1 web www-data   66 Nov  2 00:45 uploads -> /srv/www/australiascience.tv/shared//mnt/disks/asc-uploads/uploads

Clearly project_shared_children is not the way to go.

I’m hoping to do this properly and updating the link manually seems like a bad idea, so:

  • Is there any other way to do this within the Trellis configuration? or
  • Should I read up on deployment hooks and update the link using those?

Thanks in advance for any suggestions!

How about just mounting the persistent disk as the webroot, i.e., at /srv/www? Then you wouldn’t have to deal with the moving symlinks with the release directories and your disk has a more complete set of site files (not just uploads). Maybe that doesn’t suit your purposes.

Or, how about leaving project_shared_children untouched, so it keeps its default uploads stuff, but then you mount the persistent disk at /srv/www/australiascience.tv/shared/uploads or just /srv/www/australiascience.tv/shared? Maybe that doesn’t suit your purposes either.

If none of the above, I guess you could indeed use a deploy hook to include a file with your custom version of these tasks to accommodate a mount point outside the regular shared directory.

Or, push back and we can see about making the project_shared_children accommodate both absolute and relative src paths. I just don’t remember it ever coming up before (i.e., not in high demand?).

2 Likes

Thanks so much @fullyint.

I’ll give it a go. I was following GC’s instructions slavishly, but I guess there’s no reason the mount couldn’t be at /srv/www/australiascience.tv/shared/.

1 Like