diff --git a/meta/main.yml b/meta/main.yml index e97f518..297842f 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -16,6 +16,9 @@ galaxy_info: - all - name: Ubuntu versions: - - all + - precise + - raring + - saucy + - trusty categories: - web diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index e3efa5f..add94c8 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -1,31 +1,37 @@ --- -- name: Ensure Apache is installed (Debian). +- name: Ensure Apache is installed. apt: > name={{ item }} state=installed with_items: apache_packages -- name: Configure Apache (Debian). +- name: Configure Apache. lineinfile: > dest="{{ apache_server_root }}/ports.conf" regexp="{{ item.regexp }}" line="{{ item.line }}" state=present - with_items: - - { - regexp: "^Listen ", - line: "Listen {{ apache_listen_port }}" - } - - { - regexp: "^NameVirtualHost ", - line: "NameVirtualHost *:{{ apache_listen_port }}" - } + with_items: apache_ports_configuration_items notify: restart apache -- name: Enable Apache mods (Debian). +- name: Enable Apache mods. file: > src={{ apache_server_root }}/mods-available/{{ item }} dest={{ apache_server_root }}/mods-enabled/{{ item }} state=link with_items: apache_mods_enabled notify: restart apache + +- name: Add apache vhosts configuration. + template: > + src=vhosts-{{ apache_vhosts_version }}.conf.j2 + dest={{ apache_conf_path }}/sites-available/vhosts.conf + owner=root group=root mode=644 + notify: restart apache + when: apache_create_vhosts + +- name: Add vhost symlink in sites-enabled. + file: + src: "{{ apache_conf_path }}/sites-available/vhosts.conf" + dest: "{{ apache_conf_path }}/sites-enabled/vhosts.conf" + state: link diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index a009406..d35076b 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -12,13 +12,5 @@ regexp="{{ item.regexp }}" line="{{ item.line }}" state=present - with_items: - - { - regexp: "^Listen ", - line: "Listen {{ apache_listen_port }}" - } - - { - regexp: "^NameVirtualHost ", - line: "NameVirtualHost *:{{ apache_listen_port }}" - } + with_items: apache_ports_configuration_items notify: restart apache diff --git a/vars/Debian-precise.yml b/vars/Debian-precise.yml index 8a10280..0ba9bc8 100644 --- a/vars/Debian-precise.yml +++ b/vars/Debian-precise.yml @@ -1,11 +1,22 @@ --- apache_daemon: apache2 apache_server_root: /etc/apache2 -apache_conf_path: /etc/apache2/sites-enabled +apache_conf_path: /etc/apache2 apache_vhosts_version: "2.2" + __apache_packages: - apache2 - apache2-mpm-prefork - apache2-utils - apache2.2-bin - apache2.2-common + +apache_ports_configuration_items: + - { + regexp: "^Listen ", + line: "Listen {{ apache_listen_port }}" + } + - { + regexp: "^NameVirtualHost ", + line: "NameVirtualHost *:{{ apache_listen_port }}" + } diff --git a/vars/Debian-trusty.yml b/vars/Debian-trusty.yml index d989b78..f789f83 100644 --- a/vars/Debian-trusty.yml +++ b/vars/Debian-trusty.yml @@ -1,10 +1,17 @@ --- apache_daemon: apache2 apache_server_root: /etc/apache2 -apache_conf_path: /etc/apache2/sites-enabled +apache_conf_path: /etc/apache2 apache_vhosts_version: "2.4" + __apache_packages: - apache2 - apache2-mpm-prefork - apache2-utils - apache2-bin + +apache_ports_configuration_items: + - { + regexp: "^Listen ", + line: "Listen {{ apache_listen_port }}" + } diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 550c79a..607c3ff 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -2,9 +2,21 @@ 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 - mod_ssl - openssh + +apache_ports_configuration_items: + - { + regexp: "^Listen ", + line: "Listen {{ apache_listen_port }}" + } + - { + regexp: "^NameVirtualHost ", + line: "NameVirtualHost *:{{ apache_listen_port }}" + } \ No newline at end of file