---
- name: "install apache"
  apt: name=apache2 state=present
  sudo: yes

- name: "install fastcgi module for apache"
  apt: name=libapache2-mod-fastcgi state=present
  sudo: yes

- name: "add vhosts"
  template: >
    src=virtualhost.j2
    dest=/etc/apache2/sites-available/{{ item.shortname }}
    owner=root group=root mode=644
  with_items: sites
  when: sites is defined
  notify: restart webserver
  sudo: yes

- name: "copy index.html"
  copy: src=index.html dest=/var/www/html/index.html

- name: "copy Apache2 conf"
  copy: src={{ item }} dest=/etc/apache2/conf-available
  with_fileglob:
    - "conf-available/*"

- name: "start apache"
  service: >
    name=apache2
    state=started
    enabled=yes

---
- name: "install apache"
  apt: name=apache2 state=present
  sudo: yes

- name: "install fastcgi module for apache"
  apt: name=libapache2-mod-fastcgi state=present
  sudo: yes

- name: "add vhosts"
  template: >
    src=virtualhost.j2
    dest=/etc/apache2/sites-available/{{ item.shortname }}
    owner=root group=root mode=644
  with_items: sites
  when: sites is defined
  notify: restart webserver
  sudo: yes

- name: "copy index.html"
  copy: src=index.html dest=/var/www/html/index.html

- name: "copy Apache2 conf"
  copy: src={{ item }} dest=/etc/apache2/conf-available
  with_fileglob:
    - "conf-available/*"

- name: "Enable Required Apache module"
  shell: a2enmod actions fastcgi alias

- name: "Enable Required Apache configs"
  shell: a2enconf php5-fpm

- name: "start apache"
  service: >
    name=apache2
    state=started
    enabled=yes

Enable apache mods and configs
Enable apache mods and configs
