From 6dbbb6d947a48f4e10a4d0205a3df73bb1914de7 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 10 Mar 2023 10:53:58 -0600 Subject: [PATCH] feat: allow overriding document_root #15 --- defaults/main.yml | 1 + templates/etc/apache2/sites-available/site/body.j2 | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index 53071ac..ff99869 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,6 +14,7 @@ # apache2_sites: # - id: mysite (required) # name: mysite.local (required) +# document_root: "" # ip: '*' # port: 80 # state: present diff --git a/templates/etc/apache2/sites-available/site/body.j2 b/templates/etc/apache2/sites-available/site/body.j2 index d710496..c1415d7 100644 --- a/templates/etc/apache2/sites-available/site/body.j2 +++ b/templates/etc/apache2/sites-available/site/body.j2 @@ -1,5 +1,9 @@ ServerName {{ item.name }} + {% if item.document_root is defined %} + DocumentRoot {{ item.document_root }} + {% else %} DocumentRoot {{ apache2_sites_basedir }}/{{ item.id }}/htdocs + {% endif %} {% for value in item.aliases|default([]) %} ServerAlias {{ value }} {% endfor %} @@ -12,7 +16,11 @@ # --- directories ----------------------------------------------------------- + {% if item.document_root is defined %} + + {% else %} + {% endif %} AllowOverride All Options FollowSymLinks Require all granted