Run Trellis server setup directly on server

Is it possible to run trellis directly on a server? Basically I want to take advantage of all the best practices in server configuration that Trellis provides, but not have to set up things locally, since we have some clients that don’t require custom development and just need a server to run on. Provisioning a Ubuntu vps, then running a trellis setup would be the ideal for these types of customers.

It’s definitely possible. In fact, the default Vagrant setup runs Trellis locally on the VM via Vagrant’s ansible_local provisioner to avoid requiring installing the dependencies on your host computer.

And Trellis itself uses this method for CI on GitHub Actions: trellis/integration.yml at a746077c7859706c12af60ed6cf9d29355612cbb · roots/trellis · GitHub

The main thing you need to change is the inventory: trellis/inventory at a746077c7859706c12af60ed6cf9d29355612cbb · roots/trellis · GitHub

Here’s an example. Key part being ansible_connection=local to avoid using the normal SSH connection. I might be forgetting something but I think that’s basically all you need to change.

Thanks for the quick response - but I think I’m still somewhat unclear on what commands exactly I would run to do this. Would it be via the trellis cli, or would I just use ansible + a manual clone of the trellis repository?

Would it be

  • Install Ansible
  • Clone Trellis repo from github
  • Change the inventory value in integration.yml
  • Run integration.yml as an ansible playbook

I’d still recommend using trellis-cli:

  1. install trellis-cli
  2. create a new project with it (and push to a git repo)
  3. modify the default inventory files in the project for whatever environments you have
  4. run trellis provision [environment]

I didn’t use Trellis myself, but I am curious if it does have all the things you’d want to do on a production server, to secure it. I believe it was designed more for local development which might not include all of that.

I found at least one example ansible config for such things based on a writeup I often refer to called My first 10 minutes on a server and My first 5 minutes This might be a good place to start My first 2 minutes on a server - letting Ansible do the work –

I’m not sure if there are any other resources here but I also recommend for reference on server setup.

The first page of the docs say

Trellis is all about development & production parity. What does this mean? Your development virtual machine and your production are as similar as possible.

which sounds to me like it’s meant for provisioning production. Also, the rest of the stuff on their main page also implies as much.

1 Like

That’s correct. All you need is Trellis :smile:

Yeah, side discussion in supporter discord I realized I was wrong. Definitely the purpose of Trellis.

And looking through it appears that most of the things done in those guides for securing are also done or at least configurable in trellis for it’s production provisioning. I’ll leave that up though, they are good resources I think.