---
# tasks file for apache2
- name: install web components
  apt: name={{item}} state=present update_cache=yes
  loop:
    - apache2
    - python3-pip
    - python3-virtualenv
    - python3-venv
    - python3-mysqldb
    - libapache2-mod-wsgi-py3

- name: ensure apache2 started
  service: name=apache2 state=started enabled=yes

- name: ensure mod_wsgi enabled
  apache2_module: state=present name=wsgi
  notify: restart apache2

- name: copy demo app source
  copy: src=demo/app/ dest=/var/www/demo mode=0755
  notify: restart apache2

- name: copy apache virtual host config
  copy: src=demo/demo.conf dest=/etc/apache2/sites-available mode=0755
  notify: restart apache2

- name: setup python virtualenv
  pip: requirements=/var/www/demo/requirements.txt
  notify: restart apache2

- name: de-activate default apache site
  file: path=/etc/apache2/sites-enabled/000-default.conf state=absent
  notify: restart apache2

- name: activate demo apache site
  file: src=/etc/apache2/sites-available/demo.conf dest=/etc/apache2/sites-enabled/demo.conf state=link
  notify: restart apache2