--- ### TODO: replace calls to occ with nextcloud-occ script installed by role apps/nextcloud ## 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: "{{ elevate_media_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