Roots Discourse

How to use deploy_after hook?

I have a similar agenda to this thread about theme security.

I want to delete the themes, and I’m trying to understand how to use hooks.

I have a task that works:

- name: Delete WP themes
  ansible.builtin.file:
    path: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/web/wp/wp-content/themes/"
    state: absent
  with_dict: "{{ wordpress_sites }}"

I initially put it in build-after, and realized it was running too early. In the Deployments doc, the final hook listed is deploy_after. I’m seeing that the convention is to drop deploy_ from the filename of the hook, so this would be after.yml?

I put my task into after.yml (also tried deploy_after.yml) and tried putting it both in hooks folders:

  • trellis/deploy-hooks/
  • trellis/roles/deploy/hooks/

The task doesn’t run.

I see “Check if deploy_after scripts exist” in trellis/roles/deploy/tasks/main.yml exists, but due to my lack of familiarity with Ansible, I’m not clear what’s missing.

Thanks

Discussion and solutions for removing the default themes from WordPress core package: