blob: a66f85eca2826b9783b1753c31c79eecc9e9fc8f (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
- name: install apache and related packages
apt:
name: "{{ item }}"
with_items:
- rsync
- apache2
- name: enable apache modules for ssl
apache2_module:
state: present
name: "{{ item }}"
with_items:
- ssl
- rewrite
- name: install certbot
apt:
name: certbot
default_release: stretch-backports
when: letsencrypt
- name: "empty list of domains for Let's Encrypt"
shell: rm -f /etc/letsencrypt/static_sites/*
- name: "create list of domains for static sites to get Let's Encrypt certs for"
shell: |
if [ "{{ item.letsencrypt|default(false) }}" = True ]
then
listdir="/etc/letsencrypt/static_sites"
mkdir -p "$listdir"
touch "$listdir/{{ item.domain }}"
fi
with_items: "{{ static_sites }}"
- name: install script to run certbot
template:
src: deploy_static_site_certs
dest: /usr/local/sbin/deploy_static_site_certs
owner: root
group: root
mode: 755
when: letsencrypt
- name: "get initial certificate from Let's Encrypt"
shell: /usr/local/sbin/deploy_static_site_certs
- 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
|