Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow provided templates to be extended through template inheritance #95

Closed
oxyc opened this issue Apr 11, 2017 · 4 comments
Closed

Allow provided templates to be extended through template inheritance #95

oxyc opened this issue Apr 11, 2017 · 4 comments

Comments

@oxyc
Copy link
Contributor

oxyc commented Apr 11, 2017

Trellis has a convention of splitting complicated Jinja2 templates into separete blocks that can be inherited in child templates.

Eg. their nginx vhost template https://github.com/roots/trellis/blob/master/roles/wordpress-setup/templates/wordpress-site.conf.j2

Drupal VM Issue geerlingguy/drupal-vm#1254
PR #92 (blocked by #91).

@noplanman
Copy link

I see that this has been merged, but I still have a question relating to this.

How can I override the template for each individual host?
I'm new to child templates, so maybe this is a silly question, if so, sorry!

Say I have 3 sites in my installation, how can I easily have 3 completely different vhost configurations for them?

The way I do it in my personal roles is something like this:

nginx_sites:
  - name: "My Site 1"
    server_name: site1.example.com
    template: "site1.example.com.site.j2"
  - name: "My Site 2"
    server_name: site2.example.com
    template: "site2.example.com.site.j2"
  - name: "My Site 3"
    server_name: site3.example.com
    template: "site3.example.com.site.j2"

Being able to do something like this would be really great!

I've started using this role for a different project, putting everything in the nginx_vhosts.extra_parameters variable which just isn't very pretty and bloats everything.

Thanks!

oxyc added a commit to oxyc/ansible-role-nginx that referenced this issue Apr 27, 2017
oxyc added a commit to oxyc/ansible-role-nginx that referenced this issue Apr 27, 2017
@oxyc
Copy link
Contributor Author

oxyc commented Apr 27, 2017

I like it! Opened up a PR if @geerlingguy does too.

geerlingguy added a commit that referenced this issue Apr 27, 2017
Issue #95: Add support for setting template on a per vhost basis
@geerlingguy
Copy link
Owner

I, uh... think I merged this, right? #weekendBrain

@noplanman
Copy link

Yep, has been merged!

h3po pushed a commit to h3po/ansible-role-nginx that referenced this issue Aug 13, 2020
h3po pushed a commit to h3po/ansible-role-nginx that referenced this issue Aug 13, 2020
Issue geerlingguy#95: Add support for setting template on a per vhost basis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants