Roots Discourse

Multiple sites: trellis/ subfolder

I have multiple WordPress Bedrock sites, each in a project folder with site/ and trellis/ subfolder.
For provisioning the server, I would run the server.yml playbook.
Now there is a trellis/ folder for each site and they may differ in version (changes in trellis github repository).

How well are the ansible deployment and provision steps separated?
Can I just run the deployment ansible playbook of a site - what is with differences between the ansible roles/files that were used for provisioning the server and what is now used for deploying (this particular site, trellis/ sub-folder)?

Are they on the same server or does each one have its own server?

Our “default” example set up is just that. If you want multiple sites you can always use a single Trellis project to managed multiple sites. It depends on your set up though.

The sites are on the same server, but their files are managed in separate repositories (each with separate trellis/ folder for their individual site specific config).

You can just consolidate into a single Trellis “install”. Make a parent folder that looks like:

- parent_folder/
    - trellis/
    - site1/
    - site2/

Can then individual sites still be managed in separate git repositories?

Sure, if you want. Trellis just needs reference to the repos in two places:

  1. Remotely, which is fine
  2. Locally as well, so you can reference relative/absolute paths on your local disk to the cloned projects

This is very nice because now I can keep trellis as a true cloned repository from GitHub and fetch and merge changes from it, also ensuring the same ansible files are used among all apps being deployed.

How would you set up the wordpress_sites.yml to enable this as this is the part that confuses me slightly?

Because I would like to do this for staging sites i.e. just use one server and then seperate servers for each live site.

It might also be beneficial and cost effective the multiple very small sites both staging and live with multiple sites on them initially.

Can you show what you tried? Or what you would try? LIke I said before, the “sites” can live anywhere, they just need Git remotes and local paths to point to them.

I will have a bash, I just wondered what the correct procedure would be to do this.

I can understand that the server.yml would set up the server with all the necessary software and I’m ok with that and using successfully so far.

I can understand the deploy.yml file will deploy said theme and codebase and restart nginx for any particular dev project i have running locally from a git base.

What i need to do if i understand this correctly, is run another deploy from another local dev site to that same server. What I am unsure of is will nginx recognise the second site and will it be setup correctly on that server to handle the second site without having to run another server.yml, which will probably destroy the first site…

My idea is to run a single droplet just for staging sites as they will not be getting much load, and maybe another single droplet for production sites that are very small in size and traffic, thus saving costs etc and management time.

Its just an idea, i did addrsss it pretty poorly here Trellis with Nginx Virtual Hosts on a single Digital Ocean Droplet but @benword said it wasn’t a very good idea but I’m unsure why?

Here’s an example wordpress_sites set up with multiple sites (some config formats out-of-date).

If/when you add a new site to wordpress_sites, you would need to run server.yml just for the letsencrypt role (if you’re using Let’s Encrypt) and the wordpress-setup role. The wordpress-setup creates an nginx conf for your new site. You could add --tags letsencrypt or --tags wordpress to your command to run only these roles. Then you would need to run deploy.sh or deploy.yml to deploy the new site.

Running server.yml or deploy.yml will never destroy any sites on the server.

Explore these threads (and their links) for ideas on multiple sites with one Trellis:




3 Likes

Perfect, i’ll have look at this and see how i get on.

I’m assuming I can do this in the staging env setup and then deploy the production ones to seperate servers if needs be.

If I understand correctly if i need to add a new site to existing DO droplet i would run server.yml then deploy the new site to that server.

How about single trellis / single VPS / multiple sites? How do we handle mail.yml settings for each site?

1 Like

SMTP plugin is one way, I’d need to check the code for a trellis.

1 Like

can i have multiple sites on a single trellis install that share plugins ?