I agree with Ben that Trellis doesn’t “deploy” to development (and it probably shouldn’t). But if you want to leave out the concept “deploy,” here are a couple possibilities (among many) for having Trellis run extra tasks on all environments, including development.
If your tasks should run every time (with dev.yml and deploy.yml), for staging and production you could set them up using deploy hooks, as you’ve mentioned. For development, you could modify the Trellis core file
wordpress-install/tasks/main.yml and add the following include after the WordPress install.
- include: deploy-hooks/my-tasks.yml
Now those tasks will run every time
dev.yml runs via
vagrant up or
vagrant provision. You’ll need to have set up your tasks to be idempotent so they can safely run every time.
Alternatively, you could just create a new role
my-role and add it to the end of
If you will run your tasks only occasionally you could make a playbook
my-playbook.yml and add your tasks as a tasks list, role or includes. You could then run your playbook whenever you want, for example:
ansible-playbook my-playbook.yml -i hosts/production
Note that for the command to work on development, you must add some info to your
~/.ssh/config file. Assuming your
hosts/development still has
127.0.0.1, run the following command:
vagrant ssh-config --host 127.0.0.1
Now add the output info to the end of your
~/.ssh/config. You could automate this ssh config setup for dev using the idea in roots/trellis#314.
Now you can run the tasks on dev with the following command:
ansible-playbook my-playbook.yml -i hosts/development
The first option above has the advantage that you don’t have to run any extra commands. The second option does require an extra command, but has the advantage of keeping your custom tasks/edits more separated from Trellis core files.