{% if ansible_os_family == "Debian" %}

{# On Ubuntu 16.04 we can include the default config, other versions require explicit config #}
{% if ansible_distribution_version == "16.04" %}
Include /etc/apache2/apache2.conf

{% else %}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
LogLevel warn
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

Include mods-available/ssl.load
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*conf

<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

{% endif %}

{% elif ansible_os_family == "FreeBSD" %}
Include /usr/local/etc/apache24/httpd.conf
LoadModule ssl_module        libexec/apache24/mod_ssl.so
LoadModule dav_module        libexec/apache24/mod_dav.so
LoadModule dav_svn_module    libexec/apache24/mod_dav_svn.so
LoadModule authz_svn_module  libexec/apache24/mod_authz_svn.so
{% elif ansible_os_family == "Suse" %}
Include /etc/apache2/httpd.conf
Include mods-available/ssl.load
LoadModule dav_module       /usr/lib64/apache2/mod_dav.so
LoadModule dav_svn_module   /usr/lib64/apache2/mod_dav_svn.so
{% elif ansible_os_family == "Alpine" %}
Include /etc/apache2/httpd.conf
LoadModule dav_module       /usr/lib/apache2/mod_dav.so
LoadModule dav_svn_module   /usr/lib/apache2/mod_dav_svn.so
{% elif ansible_os_family == "RedHat" %}
Include /etc/httpd/conf/httpd.conf
{% endif %}

PidFile {{ subversion_server_dir }}/apache.pid
Listen {{ subversion_repo_ip }}:{{ apache_port }} https
SSLEngine on
SSLCertificateFile	{{ subversion_server_dir }}/server.pem
SSLCertificateKeyFile {{ subversion_server_dir }}/server.key
SSLCertificateChainFile {{ subversion_server_dir }}/server.pem
ErrorLog {{ subversion_server_dir }}/apache2-error.log

<Location /svn>
   DAV svn
   SVNParentPath {{ subversion_server_dir }}
{% if ansible_distribution == "CentOS" and ansible_distribution_version.startswith("6") %}
   Allow from all
{% else %}
   Require all granted
{% endif %}
</Location>

<Location /svnauth>
    DAV svn
    SVNParentPath {{ subversion_server_dir }}
    AuthType Basic
    AuthName "Subversion repositories"
    AuthUserFile {{ subversion_server_dir }}/svn-auth-users
    Require valid-user
</Location>
