diff --git a/tasks/main.yml b/tasks/main.yml index db0d99e..db35de4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -20,7 +20,7 @@ - name: Add apache vhosts configuration. template: > - src=vhosts.conf.j2 + src=vhosts-{{ apache_vhosts_version }}.conf.j2 dest={{ apache_conf_path }}/vhosts.conf owner=root group=root mode=644 notify: restart apache diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index f150175..a009406 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -1,12 +1,12 @@ --- -- name: Ensure Apache is installed (RedHat). +- name: Ensure Apache is installed. yum: > name={{ item }} state=installed enablerepo={{ apache_enablerepo }} with_items: apache_packages -- name: Configure Apache (RedHat). +- name: Configure Apache. lineinfile: > dest={{ apache_server_root }}/conf/{{ apache_daemon }}.conf regexp="{{ item.regexp }}" diff --git a/templates/vhosts.conf.j2 b/templates/vhosts-2.2.conf.j2 similarity index 100% rename from templates/vhosts.conf.j2 rename to templates/vhosts-2.2.conf.j2 diff --git a/templates/vhosts-2.4.conf.j2 b/templates/vhosts-2.4.conf.j2 new file mode 100644 index 0000000..496f27a --- /dev/null +++ b/templates/vhosts-2.4.conf.j2 @@ -0,0 +1,22 @@ + +DirectoryIndex index.php index.html + +{# Set up VirtualHosts - servername and documentroot are required. #} +{% for vhost in apache_vhosts %} + + ServerName {{ vhost.servername }} + DocumentRoot {{ vhost.documentroot }} +{% if vhost.serveradmin is defined %} + ServerAdmin {{ vhost.serveradmin }} +{% endif %} + + AllowOverride All + Options -Indexes +FollowSymLinks + Require all granted + +{% if vhost.extra_parameters is defined %} + {{ vhost.extra_parameters }} +{% endif %} + + +{% endfor %} diff --git a/vars/Debian-precise.yml b/vars/Debian-precise.yml index 62f51e2..8a10280 100644 --- a/vars/Debian-precise.yml +++ b/vars/Debian-precise.yml @@ -2,6 +2,7 @@ apache_daemon: apache2 apache_server_root: /etc/apache2 apache_conf_path: /etc/apache2/sites-enabled +apache_vhosts_version: "2.2" __apache_packages: - apache2 - apache2-mpm-prefork diff --git a/vars/Debian-trusty.yml b/vars/Debian-trusty.yml index cfcaa8a..d989b78 100644 --- a/vars/Debian-trusty.yml +++ b/vars/Debian-trusty.yml @@ -2,6 +2,7 @@ apache_daemon: apache2 apache_server_root: /etc/apache2 apache_conf_path: /etc/apache2/sites-enabled +apache_vhosts_version: "2.4" __apache_packages: - apache2 - apache2-mpm-prefork diff --git a/vars/RedHat.yml b/vars/RedHat.yml index e69d549..550c79a 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -2,6 +2,7 @@ apache_daemon: httpd apache_server_root: /etc/httpd apache_conf_path: /etc/httpd/conf.d +apache_vhosts_version: "2.2" __apache_packages: - httpd - httpd-devel