Skip to content

Commit

Permalink
feat: make site's basedir configurable
Browse files Browse the repository at this point in the history
Merge branch 'LarsKollstedt-allow_changing_docroot_basedirectory'
  • Loading branch information
franklinkim committed Feb 5, 2020
2 parents 2546efd + 7eaddd8 commit 8b4a8e0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ Here is a list of all the default variables for this role, which are also availa
# packages (versions)
apache2_packages:
- apache2
# where do we have our document roots (Default /var/www means /var/www/<SiteId>/htdocs)
apache2_docroot_basedir: /var/www
# ports to listen to
apache2_ports: [80]
# ssl ports to listen to
Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ apache2_modules: []
apache2_confs: []
# enabled/disabled sites
apache2_sites: []
# where do we have our document roots (default /var/www means /var/www/<SiteId>/htdocs)
apache2_sites_basedir: /var/www
# default site template file
apache2_sites_template: etc/apache2/sites-available/site.j2
# remove the default host
Expand Down
2 changes: 1 addition & 1 deletion tasks/manage_sites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- name: Creating webroots
file:
dest: "/var/www/{{ item.id }}/htdocs"
dest: "{{ apache2_sites_basedir }}/{{ item.id }}/htdocs"
state: directory
when: item.add_webroot is defined and item.add_webroot
with_items: "{{ apache2_sites }}"
Expand Down
4 changes: 2 additions & 2 deletions templates/etc/apache2/sites-available/site/body.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ServerName {{ item.name }}
DocumentRoot /var/www/{{ item.id }}/htdocs
DocumentRoot {{ apache2_sites_basedir }}/{{ item.id }}/htdocs
{% for value in item.aliases|default([]) %}
ServerAlias {{ value }}
{% endfor %}
Expand All @@ -12,7 +12,7 @@

# --- directories -----------------------------------------------------------

<Directory /var/www/{{ item.id }}/htdocs>
<Directory {{ apache2_sites_basedir }}/{{ item.id }}/htdocs>
AllowOverride All
Options FollowSymLinks
Require all granted
Expand Down
2 changes: 1 addition & 1 deletion templates/etc/apache2/sites-available/site/htpasswd.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Directory /var/www/{{ item.id }}/htdocs>
<Directory {{ apache2_sites_basedir }}/{{ item.id }}/htdocs>
AuthType Basic
AuthBasicProvider file
AuthUserFile /etc/htpasswd/{{ item.auth.file }}
Expand Down

0 comments on commit 8b4a8e0

Please sign in to comment.