blob: 0f9413b939669c12c6ff6502ad77a1535d09b30e (
plain) (
blame)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
---
- name: create zfs datasets
when: nextcloud_zfs is defined
block:
- name: create zfs base dataset
zfs:
name: "{{ nextcloud_zfs.pool }}/{{ nextcloud_zfs.name }}"
state: present
extra_zfs_properties:
quota: "{{ nextcloud_zfs.size }}"
- name: create zfs volumes for instances
loop: "{{ nextcloud_instances | dict2items }}"
loop_control:
label: "{{ item.key }} ({{ item.value.quota }})"
zfs:
name: "{{ nextcloud_zfs.pool }}/{{ nextcloud_zfs.name }}/{{ item.key }}"
state: present
extra_zfs_properties:
quota: "{{ item.value.quota }}"
- name: configure nextcloud base bath
set_fact:
nextcloud_base_path: "{{ zfs_zpools[nextcloud_zfs.pool].mountpoint }}/{{ nextcloud_zfs.name }}"
- name: create instance subdirectories
when: nextcloud_zfs is not defined
loop: "{{ nextcloud_instances | list }}"
file:
path: "{{ nextcloud_base_path }}/{{ item }}"
state: directory
- name: add group for nextcloud app
group:
name: nc-app
gid: "{{ nextcloud_app_gid }}"
- name: add user for nextcloud app
user:
name: nc-app
uid: "{{ nextcloud_app_uid }}"
group: nc-app
password: "!"
- name: create nextcloud app subdirectory
loop: "{{ nextcloud_instances | list }}"
file:
path: "{{ nextcloud_base_path }}/{{ item }}/nextcloud"
owner: "{{ nextcloud_app_uid }}"
group: "{{ nextcloud_app_gid }}"
state: directory
- name: add group for nextcloud db
group:
name: nc-db
gid: "{{ nextcloud_db_gid }}"
- name: add user for nextcloud db
user:
name: nc-db
uid: "{{ nextcloud_db_uid }}"
group: nc-db
password: "!"
- name: create nextcloud database subdirectory
loop: "{{ nextcloud_instances | dict2items}}"
loop_control:
label: "{{ item.key }} ({{ item.value.database.type }})"
file:
path: "{{ nextcloud_base_path }}/{{ item.key }}/{{ item.value.database.type }}"
owner: "{{ nextcloud_db_uid }}"
group: "{{ nextcloud_db_gid }}"
state: directory
- name: create auxiliary config directory
loop: "{{ nextcloud_instances | list }}"
file:
path: "{{ nextcloud_base_path }}/{{ item }}/config"
state: directory
- name: create apache vhost config
loop: "{{ nextcloud_instances | list }}"
template:
src: apache-site.conf.j2
dest: "{{ nextcloud_base_path }}/{{ item }}/config/apache-site.conf"
- name: configure apache to run on port 8443 only
loop: "{{ nextcloud_instances | list }}"
copy:
content: |
Listen 8443
dest: "{{ nextcloud_base_path }}/{{ item }}/config/ports.conf"
- name: create tls cert/key directory
loop: "{{ nextcloud_instances | list }}"
file:
path: "{{ nextcloud_base_path }}/{{ item }}/config/tls"
state: directory
- name: generate tls private key for apache
loop: "{{ nextcloud_instances | list }}"
openssl_privatekey:
path: "{{ nextcloud_base_path }}/{{ item }}/config/tls/nextcloud.key"
mode: 0640
owner: root
group: nc-app
- name: generate csr for selfsigned certifacate
loop: "{{ nextcloud_instances | list }}"
openssl_csr:
path: "{{ nextcloud_base_path }}/{{ item }}/config/tls/nextcloud.csr"
privatekey_path: "{{ nextcloud_base_path }}/{{ item }}/config/tls/nextcloud.key"
common_name: "nextcloud-{{ item }}"
## TODO: fix idempotence
- name: generate tls self-signed certificate for apache
loop: "{{ nextcloud_instances | list }}"
openssl_certificate:
path: "{{ nextcloud_base_path }}/{{ item }}/config/tls/nextcloud.crt"
privatekey_path: "{{ nextcloud_base_path }}/{{ item }}/config/tls/nextcloud.key"
csr_path: "{{ nextcloud_base_path }}/{{ item }}/config/tls/nextcloud.csr"
provider: selfsigned
- name: generate pod manifests
loop: "{{ nextcloud_instances | dict2items }}"
loop_control:
label: "{{ item.key }}"
template:
src: "pod-with-{{ item.value.database.type }}.yml.j2"
dest: "/etc/kubernetes/manifests/{{ item.key }}.yml"
mode: 0600
- name: install cron trigger script
loop: "{{ nextcloud_instances | list }}"
template:
src: run-cron.sh.j2
dest: "{{ nextcloud_base_path }}/{{ item }}/config/run-cron.sh"
mode: 0755
- name: install template systemd unit for cron trigger
template:
src: cron@.service.j2
dest: /etc/systemd/system/nextcloud-cron@.service
- name: install systemd timer unit
loop: "{{ nextcloud_instances | list }}"
template:
src: cron-.timer.j2
dest: "/etc/systemd/system/nextcloud-cron-{{ item }}.timer"
- name: start/enable cron trigger systemd timer
loop: "{{ nextcloud_instances | list }}"
systemd:
daemon_reload: yes
name: "nextcloud-cron-{{ item }}.timer"
state: started
enabled: yes
- name: configure nginx vhost
loop: "{{ nextcloud_instances | dict2items }}"
include_role:
name: nginx/vhost
vars:
nginx_vhost:
name: "{{ item.key }}"
content: "{{ lookup('template', 'nginx-vhost.conf.j2') }}"
acme: true
hostnames: "{{ item.value.hostnames }}"
|