summaryrefslogtreecommitdiff
path: root/roles/apache_server/tasks/main.yml
blob: 0f59f6773c1b34f5d72bc36f2e22715a7baafe88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
- name: install rsync (so one can publish files via server)
  apt:
    name: rsync

- name: install apache2
  apt: name=apache2

- name: create dirs for static site contents
  file:
    state: directory
    path: "/srv/http/{{ item.domain }}"
    owner: "{{ item.owner }}"
    group: "{{ item.owner }}"
    mode: 0755
  with_items: "{{ static_sites }}"

- name: create log dirs for websites
  file:
    state: directory
    path: "/var/log/apache2/{{ item.domain }}"
    owner: www-data
    group: www-data
    mode: 0755
  with_items: "{{ static_sites }}"

- name: configure apache to serve static sites
  template:
    src: virtualhost.conf.tmpl
    dest: "/etc/apache2/sites-available/{{ item.domain }}.conf"
    owner: root
    group: root
    mode: 0644
  with_items: "{{ static_sites }}"

- name: "install htpasswd files"
  copy:
    content: "{{ item.htpasswd }}"
    dest: "/srv/http/{{ item.domain }}.htpasswd"
    owner: root
    group: root
    mode: 0644
  with_items: "{{ static_sites }}"
  when: item.htpasswd is defined

- name: enable apache sites
  shell: a2ensite "{{ item.domain }}"
  with_items: "{{ static_sites }}"
  notify:
    - restart apache