Filter Nginx includes by sites present on target server #1573
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One for those of us using multiple remote servers with Trellis.
Currently, Trellis templates out anything you put into
nginx-includes/
to the remote servers. Take the following:Assume server1 has a different site(s) to server2, and perhaps staging1 and staging 2 have additional sites. Your Nginx includes folder might look like this:
All servers will end up with all Nginx includes files, even if the sites don't exist on that server:
This PR filters the Nginx includes that are to be 'included' by combining the sites that exist on the target server (taken from wordpress_sites keys) with a default 'all'. This follows with the default setup shown in the docs.
Also included is the ability to override the default 'all' folder. I've only included this because it is possible to override the block in the Nginx conf template and if someone did that, they may also want to determine their own Nginx includes locations.
To override or otherwise add to the Nginx includes locations, in e.g.
group_vars/all/main.yml
you can doNote: in testing, the folders for sites not present on a remote are not cleaned up if they already exist but the files inside them are. That's to do with what happens when setting
nginx_includes_d_cleanup: true
which is a separate issue.