WIP: Jinja2 for Web server templates #5994
Closed
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.
What this PR does
Replaces python string formatting with Jinja2 when generating web-server configurations. This also allows the three separate Nginx templates to be combined into one, replacing duplicated config stanzas by some Jinja2 conditionals.
In future this may allow the OMERO.web Ansible role to deterministically generate and update the Nginx config. Currently this requires some logic to guess when the config needs to be regenerated: https://github.com/openmicroscopy/ansible-role-omero-web/blob/2.0.1/tasks/web-nginx.yml#L12-L37
For example: currently if you make an OMERO config change after the nginx config has already been generated it won't be updated until you upgrade OMERO.web. (Note that Ansible does not support remote templates so it would require an extra step: https://www.reddit.com/r/ansible/comments/7r0eno/using_a_template_on_the_remote_host/dste442/)
TODO: Currently the templated variable names are unchanged, though if this is incorporated into the Ansible role they will need to be renamed.
This PR is on top of #5995 to make it easier to review.
Testing this PR
It should be enough to verify the unit tests pass with only whitespace changes to the reference templates as shown by this filtered view: https://github.com/openmicroscopy/openmicroscopy/pull/5994/files?file-filters%5B%5D=.conf&w=1
Related reading