---
- name: install packages
  apt:
    name: "{{ item }}"
    state: present
  with_items:
    - apache2
    - apache2-utils

- name: install module packages
  apt:
    name: "{{ item }}"
    state: present
  with_items: "{{ apache_apt_install }}"

- name: enable apache mods
  file:
    src: "/etc/apache2/mods-available/{{ item }}"
    dest: "/etc/apache2/mods-enabled/{{ item }}"
    state: link
  with_items: "{{ apache_mods_enabled }}"
  notify: restart apache

- name: disable apache mods
  file:
    path: "/etc/apache2/mods-enabled/{{ item }}"
    state: absent
  with_items: "{{ apache_mods_disabled }}"
  notify: restart apache

- name: stub ports file
  copy:
    src: ports.conf
    dest: /etc/apache2/ports.conf
    mode: 0644
    owner: root
    group: root
  notify: restart apache

- name: set-up ssl if any vhosts require it
  include: ssl.yml
  when:  "{{ apache_vhosts | selectattr('ssl', 'defined') | map(attribute='ssl') | sum }}"

- name: set-up apache vhosts
  include: vhosts.yml

- meta: flush_handlers

- name: start apache
  service:
    name: apache2
    state: started
    enabled: yes

---
- name: install packages
  apt:
    name: "{{ item }}"
    state: present
  with_items:
    - apache2
    - apache2-utils

- name: install module packages
  apt:
    name: "{{ item }}"
    state: present
  with_items: "{{ apache_apt_install }}"

- name: enable apache mods
  file:
    src: "/etc/apache2/mods-available/{{ item }}"
    dest: "/etc/apache2/mods-enabled/{{ item }}"
    state: link
  with_items: "{{ apache_mods_enabled }}"
  notify: restart apache

- name: disable apache mods
  file:
    path: "/etc/apache2/mods-enabled/{{ item }}"
    state: absent
  with_items: "{{ apache_mods_disabled }}"
  notify: restart apache

- name: stub ports file
  copy:
    src: ports.conf
    dest: /etc/apache2/ports.conf
    mode: 0644
    owner: root
    group: root
  notify: restart apache

- name: Remove ubuntu's default welcome page
  file:
    path: /var/www/html/index.html
    state: absent

- name: set-up ssl if any vhosts require it
  include: ssl.yml
  when:  "{{ apache_vhosts | selectattr('ssl', 'defined') | map(attribute='ssl') | sum }}"

- name: set-up apache vhosts
  include: vhosts.yml

- meta: flush_handlers

- name: start apache
  service:
    name: apache2
    state: started
    enabled: yes

Remove the default welcome page
Remove the default welcome page

Apache on ubuntu ships with a webroot preconfigured and an index.html
ready to go. This obviously is treated with higher priority than index
files provided by the vhost. Remove the ubuntu one so our vhost's shine
through.

Signed-off-by: Jamie Lennox <1b9801e8e46f6bd96338b24e58c84c4f37762fc2@gmail.com>
