How is the {{ site }} variable resolved in Trellis

Hello,

I’ve been trying to reuse some of Trellis’ roles to create a couple new tasks. I’ve spent now a while trying to figure out how Ansible resolved the {{ site }}. I know that {{ site }} is a n item from the map in wordpress_sties.yml. Hoever, the variable is not explicitly assigned value. Take deploy.yml as an example:

  vars:
    project: "{{ wordpress_sites[site] }}"
    project_root: "{{ www_root }}/{{ site }}"

How is {{ site }} resolved in {{ project_root }} ?

I created a new deployment playbook - {{ deploy-non-wp.yml }} and included this:

  vars:
    project: "{{ non_wordpress_sites[non_wp_site] }}"
    project_root: "{{ www_root }}/{{ non_wp_site }}"

along with a new config file non_wordpress_sites.yml which follows the strcutory of wordpress_sites.yml.

Still, upon running the playbook, I receive the error message:

‘non_wp_site’ is undefined"

even in this simple task:

---
- name: Create project root directory
  file:
    path: "{{ project_root }}"
    state: directory

You pass {{ site }} to ansible either through running the deploy script:

// site name === {{ site  }}
./deploy.sh <environment> <site name>

Or through the ansible command that deploy.sh itself calls:

// site === {{ site }}
ansible-playbook deploy.yml -e "site=<site name> env=<environment>"
3 Likes