-
Notifications
You must be signed in to change notification settings - Fork 48
/
main.yml
96 lines (82 loc) · 3.32 KB
/
main.yml
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
---
- name: generate admin passwd if nextcloud_passwd is empty
set_fact:
nextcloud_passwd: "{{ lookup('password', '{{ nextcloud_credential_store }}/nextcloud_admin_secret chars=ascii_letters,digits length=32') }}"
when: nextcloud_passwd == ''
- name: first setup nextcloud
shell: >
docker exec --user www-data nextcloud php occ maintenance:install
--database {{ nextcloud_db_type }} --database-host nextcloud-db --database-name {{ nextcloud_db_name }}
--database-table-prefix {{ nextcloud_db_prefix }} --database-user {{ nextcloud_db_user }} --database-pass {{ nextcloud_db_passwd }}
--admin-user {{ nextcloud_admin }} --admin-pass {{ nextcloud_passwd }} --data-dir {{ nextcloud_container_data_dir }}
when: ( not config_php.stat.exists )
register: first_setup_nextcloud
- name: configure nextcloud
block:
- name: set nextcloud system config.php values
shell: '{{ docker_occ_cmd }} config:system:set {{ item }}'
loop: '{{ nextccloud_system_config }}'
- name: set nextcloud mail config.php values
shell: '{{ docker_occ_cmd }} config:system:set {{ item }}'
loop: '{{ nextccloud_mail_config }}'
when:
- nextcloud_configure_mail|bool
- name: install {{ item.name }} app
shell: '{{ docker_occ_cmd }} app:install {{ item.name }}'
args:
creates: '{{ nextcloud_www_dir }}/apps/{{ item.name }}'
loop: '{{ nextcloud_app_config }}'
- name: '{{ item.state }} {{ item.name }} app'
shell: '{{ docker_occ_cmd }} app:{{ item.state }} {{ item.name }}'
loop: '{{ nextcloud_app_config }}'
- name: backup jobs, upgrade apps and database tuning
shell: '{{ docker_occ_cmd }} {{ item }}'
loop:
- background:cron
- upgrade
- app:update --all
- db:add-missing-indices
- db:convert-filecache-bigint
when: ( first_setup_nextcloud is changed ) or ( force_nextcloud_config|default(false) )
- name: create optimize batch job
copy:
dest: /usr/local/bin/nextcloud_optimize.sh
owner: root
group: root
mode: 0755
content: |
#!/bin/bash
docker exec redis redis-cli -a {{ lookup('password', '{{ nextcloud_credential_store }}/redis_secret chars=ascii_letters,digits length=32') }} FLUSHALL
docker exec --user www-data nextcloud php occ files:scan --all
docker exec --user www-data nextcloud php occ files:scan-app-data
exit 0
- name: optimize nextcloud cronjob
cron:
name: nextcloud optimize
minute: '15'
hour: '01'
user: root
job: "/usr/local/bin/nextcloud_optimize.sh > /dev/null 2>&1"
- name: nextcloud cronjob
cron:
name: nextcloud cronjob
minute: '*/15'
user: root
job: "docker exec --user www-data nextcloud php -f cron.php > /dev/null 2>&1"
- name: run nextcloud cronjob once
shell: 'docker exec --user www-data nextcloud php -f cron.php > /dev/null 2>&1'
- name: setup collabora app in nextcloud
include_tasks: configure_collabora.yml
when:
- online_office == 'collabora'
- ansible_architecture == 'x86_64'
- name: setup onlyoffice app in nextcloud
include_tasks: configure_onlyoffice.yml
when:
- online_office == 'onlyoffice'
- ansible_architecture == 'x86_64'
- name: setup talk app in nextcloud
include_tasks: talk.yml
when:
- talk_install|bool
- (ansible_architecture == 'x86_64' or ansible_architecture == 'aarch64')