Roots Discourse

Trellis not building nginx includes on provision

Following the documentation I’m attempting to set up a simple Nginx include that contains my 301 redirects. My local folder structure looks like this

trellis/nginx-includes/mysite.com/rewrites.conf.j2

However, when I provision the server the files aren’t getting templated to the remote. When I ssh into the server, I can see that the Nginx config for my site does have the new include statement, but there is no corresponding directory at etc/nginx/includes.d so the redirects don’t exist.

I have tried running provisioning both with --tags nginx-includes as well as without. The first time I provisioned the output did show 3 changed files, but on subsequent tries it just completes with no changes reported. I’m especially confounded because I have an identical setup on a different project that works fine. I even SSHed into the remote server and created the includes.d directory myself, but upon reprovisioning the directory is still empty. I don’t know what else to try at this point.

Any insights greatly appreciated.

:thinking: strange. I’d suggest including a debug task to see if the local files are being picked up.

You can add the following:

- debug:
    var: nginx_includes_templates

in roles/wordpress-setup/tasks/nginx-includes.yml. Right after the first “Build list of Nginx includes templates” task should work.

Then re-provision with that tag again and it should output a list of files ideally.

I added the debug task and re-provisioned, and the output was

TASK [wordpress-setup : debug] 
*************************************************************************************
Hello world!
ok: [ip address]

so I guess it’s not picking up the local files. I just double-checked the folder structure and still can’t see any reason for it.

UPDATE: Ugh. Turns out I was SSHing into the wrong server when I went to check on the remote files. :man_facepalming: So of course I wasn’t seeing anything - I was looking on my staging server and thinking I was on production. Just tried again and the nginx-includes are getting templated to production as expected. Still not sure why my redirects weren’t working originally but I can sort that out now. Thanks @swalkinshaw for taking a look all the same!

1 Like