blob: 8531699c955bcd22f7a7e36156a2371dba5d2716 (
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
|
---
- name: preare nextcloud disks
import_tasks: nextcloud-lvm.yml
- name: create nextcloud config directory
file:
path: /srv/nextcloud/config/
state: directory
- name: install nextcloud fpm config snippet
template:
src: nextcloud-fpm.conf.j2
dest: /srv/nextcloud/config/nextcloud-fpm.conf
- name: create nextcloud database
mysql_db:
login_user: root
login_password: "{{ mysql_root_password }}"
db: "{{ nextcloud_db.db }}"
encoding: utf8mb4
collation: utf8mb4_general_ci
state: present
- name: create nextcloud database user
mysql_user:
login_user: root
login_password: "{{ mysql_root_password }}"
name: "{{ nextcloud_db.user }}"
password: "{{ nextcloud_db.password }}"
priv: "{{ nextcloud_db.db }}.*:SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER,CREATE TEMPORARY TABLES"
state: present
## to purge exisiting installation run the following commands (!!! will delete all data and the DB !!!):
#
# systemctl disable nextcloud-cron.timer
# systemctl stop nextcloud-cron.timer
# systemctl disable nextcloud.serivce
# systemctl stop nextcloud.service
# rm -rf /srv/nextcloud/config/nextcloud
# rm -rf /srv/ncdata/nextcloud
# rm -rf /srv/nextcloud/www
# echo "drop database nextcloud;" | mysql --defaults-extra-file=/etc/mysql/debian.cnf
#
- name: check if nextcloud is already configured
stat:
path: /srv/nextcloud/config/nextcloud/config.php
register: nextcloud_config_file
- name: running nextcloud installer
when: not nextcloud_config_file.stat.exists
docker_container:
name: nextcloud
image: nextcloud:{{ nextcloud_version }}-fpm
## for some reasons a newly created database schema is not up to date with the recommended settings...
## in case this is not needed anymore using '/bin/true' here.
command: 'su -p www-data -s /bin/sh -c "php /var/www/html/occ db:convert-filecache-bigint"'
network_mode: host
detach: no
auto_remove: yes
volumes:
- /srv/nextcloud/www:/var/www/html
- /srv/nextcloud/config/nextcloud-fpm.conf:/usr/local/etc/php-fpm.d/zzzzz.conf
- /srv/nextcloud/config/nextcloud:/var/www/html/config
- /srv/ncdata/nextcloud:/var/www/html/data
- /srv/ncdata/share:/srv/external
env:
NEXTCLOUD_UPDATE: '1'
NEXTCLOUD_TRUSTED_DOMAINS: "{{ nextcloud_hostnames | join(' ') }}"
MYSQL_DATABASE: "{{ nextcloud_db.db }}"
MYSQL_HOST: "127.0.0.1:3306"
MYSQL_USER: "{{ nextcloud_db.user }}"
MYSQL_PASSWORD: "{{ nextcloud_db.password }}"
NEXTCLOUD_ADMIN_USER: "{{ nextcloud_admin.username }}"
NEXTCLOUD_ADMIN_PASSWORD: "{{ nextcloud_admin.password }}"
- name: install nextcloud service unit
template:
src: nextcloud.service.j2
dest: /etc/systemd/system/nextcloud.service
register: nextcloud_service
- name: make sure nextcloud is started and enabled
systemd:
name: nextcloud.service
state: "{% if nextcloud_service.changed %}restarted{% else %}started{% endif %}"
enabled: yes
daemon_reload: yes
- name: basic nextcloud config
import_tasks: nextcloud-config.yml
- name: install nextcloud cron systemd units
with_items:
- service
- timer
template:
src: "nextcloud-cron.{{ item }}.j2"
dest: "/etc/systemd/system/nextcloud-cron.{{ item }}"
- name: make sure nextcloud cron is started and enabled
systemd:
name: nextcloud-cron.timer
state: started
enabled: yes
daemon_reload: yes
|