--- # Run command line installation. # the web server must be running by now in order to launch the installation - name: Trigger all pending handlers meta: flush_handlers - name: Set data folder file: path: '/var/ncdata' mode: '0750' state: directory owner: 'www-data' group: 'www-data' - name: Generate Nextcloud admin password set_fact: nextcloud_admin_pwd: "{{ lookup('password', 'passwords/web_admin.pwd length=12') }}" - name: Remove existing configuration file file: path: '{{ nextcloud_webroot }}/config/config.php' state: absent - name: Run occ installation command become_user: 'www-data' become: yes command: > php occ maintenance:install --database=mysql --database-host=127.0.0.1 --database-name=nextcloud --database-user=ncadmin --database-pass={{ nextcloud_db_pwd }} --admin-user={{ nextcloud_admin_name }} --admin-pass={{ nextcloud_admin_pwd }} --data-dir=/var/ncdata args: chdir: '{{ nextcloud_webroot }}' creates: '{{ nextcloud_webroot }}/config/config.php' notify: reload http - name: Set trusted domains become_user: 'www-data' become: yes command: 'php occ config:system:set trusted_domains {{ index }} --value="{{ item }}"' args: chdir: '{{ nextcloud_webroot }}' loop: '{{ nextcloud_trusted_domains | flatten(levels=1) }}' loop_control: index_var: index changed_when: true - name: Set trusted proxies become_user: 'www-data' become: yes command: 'php occ config:system:set trusted_proxies {{ index }} --value="{{ item }}"' args: chdir: '{{ nextcloud_webroot }}' loop: '{{ nextcloud_trusted_proxies | flatten(levels=1) }}' loop_control: index_var: index changed_when: true - name: Set other Nextcloud settings in config.php become_user: 'www-data' become: yes command: 'php occ config:system:set {{ item.name }} --value="{{ item.value }}"' args: chdir: '{{ nextcloud_webroot }}' loop: '{{ nextcloud_config_settings }}' changed_when: true - name: Set Redis Server become_user: 'www-data' become: yes command: 'php occ config:system:set {{ item.name }} --value="{{ item.value }}"' args: chdir: '{{ nextcloud_webroot }}' loop: '{{ nextcloud_redis_settings }}' - name: Install Cron job cron: name: 'Nextcloud Cron' minute: '*/15' user: 'www-data' job: 'php {{ nextcloud_webroot }}/cron.php' cron_file: 'nextcloud' - name: Inform cron method to Nextcloud become_user: 'www-data' become: yes command: 'php occ background:cron' args: chdir: '{{ nextcloud_webroot }}' - name: Set Custom Mimetype copy: src: nextcloud_custom_mimetypemapping.json dest: '{{ nextcloud_webroot }}/config/mimetypemapping.json' - name: Increase security for existing Nextcloud folders and files file: path: /var/ncdata mode: 'o-rwx' recurse: yes owner: 'www-data' group: 'www-data' state: directory