nextcloud: Support remote database server

The _nextcloud_ role originally handled setting up the PostgreSQL
database and assumed that it was running on the same server as Nextcloud
itself.  I have factored out those tasks into their own role,
_nextcloud-db_, which can be applied to a separate host.

I have also introduced some new variables (`nextcloud_db_host`,
`nextcloud_db_name`, `nextcloud_db_user`, and `nextcloud_db_password`),
which can be used to specify how to connect to the database, if it is
hosted remotely.  Since these variables are used by both the _nextcloud_
and _nextcloud-db_ roles, they are actually defined in a separate role,
_nextcloud-base_, upon which both depend.
frigate-exporter
Dustin 2024-09-02 20:29:51 -05:00
parent 226232414f
commit 924107abbe
8 changed files with 39 additions and 21 deletions

View File

@ -1,7 +1,14 @@
- hosts: nextcloud-db
vars_files:
- vault/nextcloud
roles:
- role: nextcloud-db
tags:
- nextcloud-db
- hosts: nextcloud - hosts: nextcloud
vars_files: vars_files:
- vault/nextcloud - vault/nextcloud
roles: roles:
- postgresql-server
- apache - apache
- nextcloud - nextcloud

View File

@ -0,0 +1,4 @@
nextcloud_db_name: nextcloud
nextcloud_db_host: localhost
nextcloud_db_port: ''
nextcloud_db_user: nextcloud

View File

View File

@ -0,0 +1,2 @@
dependencies:
- nextcloud-base

View File

@ -0,0 +1,19 @@
- name: ensure nextcloud database user exists
become: true
become_user: postgres
postgresql_user:
name: '{{ nextcloud_db_user }}'
password: '{{ nextcloud_db_password|d(omit) }}'
state: present
tags:
- postgresql-user
- name: ensure nextcloud database exists
become: true
become_user: postgres
postgresql_db:
name: nextcloud
owner: nextcloud
state: present
tags:
- postgresql-db

View File

@ -1,4 +1,5 @@
dependencies: dependencies:
- nextcloud-base
- role: redis - role: redis
tags: tags:
- redis - redis

View File

@ -27,21 +27,6 @@
tags: tags:
- always - always
- name: ensure nextcloud database user exists
become: true
become_user: postgres
postgresql_user:
name: nextcloud
password: '{{ nextcloud_db_password }}'
state: present
- name: ensure nextcloud database exists
become: true
become_user: postgres
postgresql_db:
name: nextcloud
owner: nextcloud
state: present
- name: ensure nextcloud is configured - name: ensure nextcloud is configured
template: template:
src: config.php.j2 src: config.php.j2

View File

@ -37,12 +37,12 @@ $CONFIG = array (
'dbtype' => 'pgsql', 'dbtype' => 'pgsql',
'version' => '{{ nc_version }}', 'version' => '{{ nc_version }}',
'overwrite.cli.url' => 'https://{{ nextcloud_server_name }}', 'overwrite.cli.url' => 'https://{{ nextcloud_server_name }}',
'dbname' => 'nextcloud', 'dbname' => '{{ nextcloud_db_name }}',
'dbhost' => 'localhost', 'dbhost' => '{{ nextcloud_db_host }}',
'dbport' => '', 'dbport' => '{{ nextcloud_db_port }}',
'dbtableprefix' => 'oc_', 'dbtableprefix' => 'oc_',
'dbuser' => 'nextcloud', 'dbuser' => '{{ nextcloud_db_user }}',
'dbpassword' => '{{ nextcloud_db_password }}', 'dbpassword' => '{{ nextcloud_db_password|d("") }}',
'installed' => true, 'installed' => true,
'ldapIgnoreNamingRules' => false, 'ldapIgnoreNamingRules' => false,
'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory', 'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',