Skip to content

Commit

Permalink
Merge branch 'allow_changing_docroot_basedirectory' of https://github…
Browse files Browse the repository at this point in the history
….com/LarsKollstedt/ansible-apache2 into LarsKollstedt-allow_changing_docroot_basedirectory
  • Loading branch information
franklinkim committed Feb 5, 2020
2 parents 2546efd + 4fb80cd commit e0cdc90
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 @@ -33,6 +33,8 @@
# 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: 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_docroot_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_docroot_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_docroot_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_docroot_basedir}}/{{ item.id }}/htdocs>
AuthType Basic
AuthBasicProvider file
AuthUserFile /etc/htpasswd/{{ item.auth.file }}
Expand Down

0 comments on commit e0cdc90

Please sign in to comment.