allow new installations by adjusting config

Also create CAN_INSTALL file to allow migrations to run.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2022-06-24 10:00:01 +02:00
parent 68d18cc624
commit ce14915060
No known key found for this signature in database
GPG Key ID: 09AA5403E54D9931
6 changed files with 49 additions and 17 deletions

View File

@ -54,11 +54,12 @@ nextcloud_docs_cont_vol: '{{ nextcloud_service_path }}/docs'
nextcloud_docs_cont_verison: '7.0.0.132'
nextcloud_docs_cont_image: 'onlyoffice/documentserver:{{ nextcloud_docs_cont_verison }}'
nextcloud_docs_cont_port: 9980
nextcloud_docs_cont_uids: { db: 107, queue: 108, app: 109 }
nextcloud_docs_cont_uids: { db: 107, queue: 108, app: 109, logs: 112 }
nextcloud_docs_host_uids:
db: '{{ 100000 + nextcloud_docs_cont_uids["db"] | int }}'
queue: '{{ 100000 + nextcloud_docs_cont_uids["queue"] | int }}'
app: '{{ 100000 + nextcloud_docs_cont_uids["app"] | int }}'
logs: '{{ 100000 + nextcloud_docs_cont_uids["logs"] | int }}'
#nextcloud_docs_secret_key: ~
# Cache ------------------------------------------------------------------------
nextcloud_cache_cont_name: '{{ nextcloud_service_name }}-cache'

View File

@ -4,6 +4,11 @@
group:
name: 'nextcloud'
gid: '{{ nextcloud_app_host_uid }}'
register: nextcloud_group
- name: Detect new installation
set_fact:
nextcloud_new_installation: '{{ nextcloud_group.changed }}'
- name: Create directory for webserver
file:
@ -17,9 +22,9 @@
- { p: '{{ nextcloud_app_cont_vol }}/data', o: '{{ nextcloud_app_host_uid }}', g: 'nextcloud' }
- { p: '{{ nextcloud_app_cont_vol }}/config',o: '{{ nextcloud_app_host_uid }}', g: 'nextcloud' }
- { p: '{{ nextcloud_db_cont_vol }}/data', o: '{{ nextcloud_db_host_uid }}', g: 'docker', m: '0777' }
- { p: '{{ nextcloud_docs_cont_vol }}/db', o: '{{ nextcloud_docs_host_uids["db"] }}', g: 'dockremap', m: '0777' }
- { p: '{{ nextcloud_docs_cont_vol }}/data', o: '{{ nextcloud_docs_host_uids["app"] }}', g: 'dockremap' }
- { p: '{{ nextcloud_docs_cont_vol }}/logs', o: '{{ nextcloud_docs_host_uids["app"] }}', g: 'dockremap' }
- { p: '{{ nextcloud_docs_cont_vol }}/db', o: '{{ nextcloud_docs_host_uids["db"] }}', g: 'dockremap', m: '0777' }
- { p: '{{ nextcloud_docs_cont_vol }}/data', o: '{{ nextcloud_docs_host_uids["app"] }}', g: 'dockremap' }
- { p: '{{ nextcloud_docs_cont_vol }}/logs', o: '{{ nextcloud_docs_host_uids["logs"] }}', g: 'dockremap' }
register: wat
- name: Create NextCloud config
@ -39,5 +44,6 @@
group: 'docker'
mode: 0640
with_items:
- 'db.env'
- 'app.env'
- 'docs.env'
- 'db.env'

View File

@ -6,19 +6,40 @@
php occ list maintenance
register: nextcloud_occ_commands
- name: Run intallation process
- name: Run installation process
when: '"maintenance:install" in nextcloud_occ_commands.stdout'
register: nextcloud_installation
command: |
docker exec -u {{ nextcloud_app_cont_uid }} \
{{ nextcloud_app_cont_name }} \
php occ maintenance:install \
--data-dir='/data'
--database='pgsql' \
--database-host='db' \
--database-port='{{ nextcloud_db_cont_port | mandatory }}' \
--database-name='{{ nextcloud_db_name | mandatory }}' \
--database-user='{{ nextcloud_db_user | mandatory }}' \
--database-pass='{{ nextcloud_db_pass | mandatory }}' \
--admin-user='{{ nextcloud_admin_username | mandatory }}' \
--admin-pass='{{ nextcloud_admin_password | mandatory }}' \
--admin-email='{{ nextcloud_admin_email | mandatory }}'
--data-dir=/data
--database=pgsql \
--database-host=db \
--database-port={{ nextcloud_db_cont_port | mandatory }} \
--database-name={{ nextcloud_db_name | mandatory }} \
--database-user={{ nextcloud_db_user | mandatory }} \
--database-pass={{ nextcloud_db_pass | mandatory }} \
--admin-user={{ nextcloud_admin_username | mandatory }} \
--admin-pass={{ nextcloud_admin_password | mandatory }} \
--admin-email={{ nextcloud_admin_email | mandatory }}
- name: Mark installation as done
set_fact:
nextcloud_new_installation: false
- name: Update NextCloud config
template:
src: 'config.php.j2'
dest: '{{ nextcloud_app_cont_vol }}/config/config.php'
owner: '{{ nextcloud_app_host_uid }}'
group: 'dockremap'
mode: 0644
register: nextcloud_config
- name: Run upgrade process
when: nextcloud_installation.changed
command: |
docker exec -u {{ nextcloud_app_cont_uid }} \
{{ nextcloud_app_cont_name }} \
php occ upgrade

1
templates/app.env.j2 Normal file
View File

@ -0,0 +1 @@
VIRTUAL_HOST='{{ nextcloud_domain }}'

View File

@ -1,8 +1,11 @@
<?php
/* https://github.com/nextcloud/server/blob/v23.0.0/config/config.sample.php */
$CONFIG = [
{# When these keys are present DB migrations are not executed. #}
{% if not nextcloud_new_installation %}
'version' => '23.0.0.10',
'installed' => true,
{% endif %}
/* AUTH */
'auth.webauthn.enabled' => {{ nextcloud_webauthn_native_enaled | to_json }},
/* ENCRYPTION */

View File

@ -5,7 +5,7 @@ services:
container_name: '{{ nextcloud_app_cont_name }}'
image: '{{ nextcloud_app_cont_image }}'
restart: 'always'
entrypoint: '/usr/local/bin/apache2-foreground'
env_file: '{{ nextcloud_service_path }}/app.env'
ports:
- '{{ nextcloud_app_cont_port }}:80'
volumes: