diff --git a/defaults/main.yml b/defaults/main.yml index 164096a..1dcecad 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -13,6 +13,9 @@ nextcloud_hostname: '' nextcloud_path_prefix: / +nextcloud_initial_admin_username: admin +nextcloud_initial_admin_password: '' + nextcloud_version: 30.0.0 nextcloud_uid: '' @@ -326,6 +329,11 @@ nextcloud_config_parameters: "{{ nextcloud_config_default_parameters + nextcloud nextcloud_config_default_parameters: | {{ ([ + { + 'key': 'trusted_domains 1', + 'value': nextcloud_hostname, + 'type': 'string', + }, { 'key': 'overwriteprotocol', 'value': 'https', diff --git a/tasks/main.yml b/tasks/main.yml index b0c326c..ba0218a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,17 +13,15 @@ ansible.builtin.include_tasks: "{{ role_path }}/tasks/install.yml" - tags: - - adjust-nextcloud-config + - post-install-all + - post-install-nextcloud block: + - when: nextcloud_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/post_install.yml" + - when: nextcloud_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/adjust_config.yml" -- tags: - - print-nextcloud-db-credentials - block: - - when: nextcloud_enabled | bool - ansible.builtin.include_tasks: "{{ role_path }}/tasks/print_db_credentials.yml" - - tags: - install-nextcloud-app-collabora block: diff --git a/tasks/post_install.yml b/tasks/post_install.yml new file mode 100644 index 0000000..26e5ea2 --- /dev/null +++ b/tasks/post_install.yml @@ -0,0 +1,34 @@ +--- + +- name: Run occ maintenance:install + ansible.builtin.command: + cmd: >- + {{ devture_systemd_docker_base_host_command_docker }} + run + --rm + --name={{ nextcloud_identifier }}-post-install + --network={{ nextcloud_container_network }} + {% if postgres_enabled and nextcloud_database_hostname == postgres_identifier and nextcloud_container_network != postgres_container_network %} + --network={{ postgres_container_network }} + {% endif %} + --user={{ nextcloud_uid }}:{{ nextcloud_gid }} + --cap-drop=ALL + --read-only + --mount=type=bind,src={{ nextcloud_data_path }},dst=/var/www/html + --env-file={{ nextcloud_config_path }}/env + {{ nextcloud_container_image_final }} + php + /var/www/html/occ + maintenance:install + --database=pgsql + --database-host={{ nextcloud_database_hostname }}:{{ nextcloud_database_port }} + --database-name={{ nextcloud_database_name }} + --database-user={{ nextcloud_database_username }} + --database-pass={{ nextcloud_database_password }} + --admin-user={{ nextcloud_initial_admin_username }} + --admin-pass={{ nextcloud_initial_admin_password }} + register: result + # On successful change: 'Nextcloud was successfully installed' in result.stdout + # To be conservative, report 'changed' for any result other than the known 'already done' error message. + changed_when: "'Command \"maintenance:install\" is not defined.' not in result.stderr" + failed_when: "'Command \"maintenance:install\" is not defined.' not in result.stderr and (result.rc != 0 or result.stderr != '')" diff --git a/tasks/print_db_credentials.yml b/tasks/print_db_credentials.yml deleted file mode 100644 index 5621fee..0000000 --- a/tasks/print_db_credentials.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -- name: Print Nextcloud DB credentials - ansible.builtin.debug: - msg: >- - Your Nextcloud database information is: - Host (`{{ nextcloud_database_hostname }}`), - Port (`{{ nextcloud_database_port }}`), - Database Name (`{{ nextcloud_database_name }}`), - Database Username (`{{ nextcloud_database_username }}`), - Database Password (`{{ nextcloud_database_password }}`)