summaryrefslogtreecommitdiff
path: root/roles/elevate/media/tasks/nextcloud-config.yml
blob: 60f923cec8a8367fc11fea664964fefe1465dc20 (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
---
  ## TODO: this is idempotent but flagging change would be nice
- name: enable files_external app
  command: docker exec -u www-data nextcloud.service /var/www/html/occ app:enable files_external
  changed_when: false


- name: check if _elevate_ user exists in nextcloud (1/2)
  command: docker exec -u www-data nextcloud.service /var/www/html/occ user:list -n --output=json
  register: nextcloud_user_list
  changed_when: false
  check_mode: false

- name: check if _elevate_ user exists in nextcloud (2/2)
  set_fact:
    nextcloud_user_list: "{{ nextcloud_user_list.stdout | from_json }}"

- name: create user _elevate_ together with group elevate in nextcloud
  command: docker exec -u www-data -e OC_PASS={{ lookup('password', '/dev/null length=30') }} nextcloud.service /var/www/html/occ user:add -n --display-name='Dummy User for files:scan' --group=elevate --password-from-env _elevate_
  when: '"_elevate_" not in nextcloud_user_list'

  ## TODO: this is idempotent but flagging change would be nice
- name: disable user _elevate_
  command: docker exec -u www-data nextcloud.service /var/www/html/occ user:disable -n _elevate_
  changed_when: false


- name: check if external storage is configured in nextcloud (1/2)
  command: docker exec -u www-data nextcloud.service /var/www/html/occ files_external:list -n --output=json
  register: nextcloud_files_external_list
  changed_when: false
  check_mode: false

- name: check if external storage is configured in nextcloud (2/2)
  set_fact:
    nextcloud_files_external_list: "{{ nextcloud_files_external_list.stdout | from_json }}"

- name: configure external storage in nextcloud
  command: docker exec -u www-data nextcloud.service /var/www/html/occ files_external:create -n --output=json --config="datadir=/srv/external/share" Share local null::null
  when: not (nextcloud_files_external_list | nextcloud_mountpoint_exists('/Share'))

  ## TODO: we assume here that the external_storage has mount_id 1
  ## TODO: this is idempotent but flagging change would be nice
- name: configure external storage in nextcloud
  command: docker exec -u www-data nextcloud.service /var/www/html/occ files_external:option 1 enable_sharing true
  changed_when: false

  ## TODO: this is idempotent but flagging change would be nice
- name: set up permission for external storage
  command: docker exec -u www-data nextcloud.service /var/www/html/occ files_external:applicable -n --output=json 1 --add-group=elevate
  changed_when: false

  ## TODO: this is idempotent but flagging change would be nice
- name: set up background tasks trigger to cron
  command: docker exec -u www-data nextcloud.service /var/www/html/occ background:cron
  changed_when: false


  ## TODO: this is idempotent but flagging change would be nice
- name: set password for admin user
  command: 'docker exec -u www-data -e "OC_PASS={{ nextcloud_admin.password }}" nextcloud.service /var/www/html/occ user:resetpassword -n --password-from-env "{{ nextcloud_admin.username }}"'
  changed_when: false


  ## TODO: this is idempotent but flagging change would be nice
- name: set nextcloud app config
  loop: "{{ nextcloud_app_config | subelements('opts') }}"
  loop_control:
    label: "{{ item.0.app }}/{{ item.1.name }} = '{{ item.1.value }}'"
  command: 'docker exec -u www-data nextcloud.service /var/www/html/occ config:app:set -n "--value={{ item.1.value }}" {{ item.0.app }} {{ item.1.name }}'
  changed_when: false