Add custom packages to provisioning?

Does trellis provide some kind of mechanism for you to add other necessary packages to the provisioning script? SSH-ing into the box and manually installing them is time consuming and kind of defeats the purpose of an automatic provisioner like vagrant + trellis.

Trellis is meant to be customized. So you can just create a new role to install any packages you need.

Here’s an example of installing some packages. So you could create a role with more packages and just add that role to dev.yml and server.yml.

1 Like

Is there a way to do it (or can there be) in the same way custom deploy hooks can be added? I have a couple backup tasks I added to provisioning in server.yml and they’ve been overwritten when merging trellis updates locally. Adding a custom vendor packages that’s referenced in requirements.yml too.

That’d be a neat feature on top of protecting me from myself.

Not sure there’s much we can do in that case. We can protect people from most merge/updates, but some places like the playbooks need to be modified.

I figured that was the case. Wasn’t sure if there was a way to have the playbook scan a folder for YAML “sub-playbooks”. Like it’s an empty folder in the main trellis repo, but if you drop a .yml file in there, it will get executed.

What about doing something like this? Say you have an empty folder check’d into github custom-roles. Part of the default trellis build has this at the end of the provisioning step:

---
- name: read custom tasks
  find:
    paths: "custom-roles"
    patterns: "*.yml"
  register: custom_tasks

- name: execute custom tasks
  include: "{{ item.path }}"
  with_items: "{{ custom_tasks.files }}"

Any yaml file kept in the custom_roles folder would now be executed when the main provisioning is over. It could be as simple as all custom tasks/roles added get executed at the end of the provisioning process, or it could become more intricate as time goes on with sub-folders and executed points during different stages of the process.

I just tested this locally, and my custom YAML files were checked for syntax and executed. I might share on github to see if there’s any interest for a feature like this.

1 Like