Enable PostgreSQL database support
This commit is contained in:
parent
2a03876360
commit
86aef332ca
4 changed files with 55 additions and 18 deletions
|
@ -34,6 +34,7 @@ nextcloud_instances:
|
||||||
- name: coop.systemausfall.org
|
- name: coop.systemausfall.org
|
||||||
user: nextcloud
|
user: nextcloud
|
||||||
database: nextcloud
|
database: nextcloud
|
||||||
|
database_type: PostgreSQL
|
||||||
hiddenservice: true
|
hiddenservice: true
|
||||||
occ_config:
|
occ_config:
|
||||||
apps:
|
apps:
|
||||||
|
@ -65,7 +66,8 @@ php_cli_config:
|
||||||
| `name` | string | Domain-Name der Instanz |
|
| `name` | string | Domain-Name der Instanz |
|
||||||
| `alias`| string | Array mit weiteren Domain-Alias-Namen für diese Instanz |
|
| `alias`| string | Array mit weiteren Domain-Alias-Namen für diese Instanz |
|
||||||
| `user` | string | Name eines anzulegenden Systemnutzers, der den PHP-FPM-Prozess ausführt |
|
| `user` | string | Name eines anzulegenden Systemnutzers, der den PHP-FPM-Prozess ausführt |
|
||||||
| `database` | string | Name der anzulegenden MariaDB-Datenbank |
|
| `database` | string | Name der anzulegenden Datenbank |
|
||||||
|
| `database_type` | string | `MariaDB` oder `PostgreSQL` |
|
||||||
| `hiddenservice` | bol | Richtet für die Instanz einen Onion Service ein |
|
| `hiddenservice` | bol | Richtet für die Instanz einen Onion Service ein |
|
||||||
- Starte anschließend das Playbook:
|
- Starte anschließend das Playbook:
|
||||||
```Shell
|
```Shell
|
||||||
|
|
|
@ -4,6 +4,7 @@ apache_custom_conf_path: /etc/apache2/conf-available
|
||||||
nextcloud_admin_user: systemausfall.org
|
nextcloud_admin_user: systemausfall.org
|
||||||
nextcloud_admin_pw: "{{ lookup('password', '/tmp/{{ item.name }}_admin_pwd length=42 chars=ascii_letters,digits') }}"
|
nextcloud_admin_pw: "{{ lookup('password', '/tmp/{{ item.name }}_admin_pwd length=42 chars=ascii_letters,digits') }}"
|
||||||
nextcloud_db_password: "{{ lookup('password', '/tmp/{{ item.name }}_db_pwd length=42 chars=ascii_letters,digits') }}"
|
nextcloud_db_password: "{{ lookup('password', '/tmp/{{ item.name }}_db_pwd length=42 chars=ascii_letters,digits') }}"
|
||||||
|
nextcloud_db_type: MariaDB
|
||||||
nextcloud_github_api_url: https://api.github.com/repos/nextcloud/server/releases/latest
|
nextcloud_github_api_url: https://api.github.com/repos/nextcloud/server/releases/latest
|
||||||
nextcloud_dl_url: "https://download.nextcloud.com/server/releases/nextcloud-{{ latest_version.stdout }}.tar.bz2"
|
nextcloud_dl_url: "https://download.nextcloud.com/server/releases/nextcloud-{{ latest_version.stdout }}.tar.bz2"
|
||||||
nextcloud_root: /data/nextcloud
|
nextcloud_root: /data/nextcloud
|
||||||
|
|
|
@ -1,18 +1,40 @@
|
||||||
---
|
---
|
||||||
- name: "Database | Erstelle Datenbank | {{ item.name }}"
|
- name: "Richte MariaDB-Datenbank ein"
|
||||||
community.mysql.mysql_db:
|
when: item.database_type == "MariaDB"
|
||||||
name: "{{ item.database }}"
|
block:
|
||||||
state: present
|
- name: "Database | Erstelle Datenbank | {{ item.name }}"
|
||||||
login_unix_socket: "{{ mysql_socket }}"
|
community.mysql.mysql_db:
|
||||||
login_user: root
|
name: "{{ item.database }}"
|
||||||
|
state: present
|
||||||
|
login_unix_socket: "{{ mysql_socket }}"
|
||||||
|
login_user: root
|
||||||
|
|
||||||
- name: "Database | Richte Datenbank-Benutzer ein | {{ item.name }}"
|
- name: "Database | Richte Datenbank-Benutzer ein | {{ item.name }}"
|
||||||
community.mysql.mysql_user:
|
community.mysql.mysql_user:
|
||||||
name: "{{ item.database }}"
|
name: "{{ item.database }}"
|
||||||
host: "{{ inventory_hostname }}"
|
host: "{{ inventory_hostname }}"
|
||||||
password: "{{ nextcloud_db_password }}"
|
password: "{{ nextcloud_db_password }}"
|
||||||
priv: "{{ item.database }}.*:ALL"
|
priv: "{{ item.database }}.*:ALL"
|
||||||
state: present
|
state: present
|
||||||
login_unix_socket: "{{ mysql_socket }}"
|
login_unix_socket: "{{ mysql_socket }}"
|
||||||
login_user: root
|
login_user: root
|
||||||
update_password: on_create
|
update_password: on_create
|
||||||
|
|
||||||
|
- name: "Richte PostgreSQL-Datenbank ein"
|
||||||
|
when: item.database_type == "PostgreSQL"
|
||||||
|
block:
|
||||||
|
- name: "Database | Erstelle Datenbank | {{ item.name }}"
|
||||||
|
community.postgresql.postgresql_db:
|
||||||
|
name: "{{ item.database }}"
|
||||||
|
encoding: UTF8
|
||||||
|
template: template0
|
||||||
|
become: true
|
||||||
|
become_user: postgres
|
||||||
|
|
||||||
|
- name: "Database | Richte Datenbank-Benutzer ein | {{ item.name }}"
|
||||||
|
community.postgresql.postgresql_user:
|
||||||
|
name: "{{ item.database }}"
|
||||||
|
password: "{{ nextcloud_db_password }}"
|
||||||
|
db: "{{ item.database }}"
|
||||||
|
become: true
|
||||||
|
become_user: postgres
|
||||||
|
|
|
@ -47,4 +47,16 @@
|
||||||
become: true
|
become: true
|
||||||
become_user: "{{ item.user }}"
|
become_user: "{{ item.user }}"
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: not nc_is_installed.stat.exists
|
when: not nc_is_installed.stat.exists and item.database_type == "MariaDB"
|
||||||
|
|
||||||
|
- name: "Nextcloud | Führe Installation aus | {{ item.name }}"
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: >
|
||||||
|
php occ maintenance:install --database "pgsql"
|
||||||
|
--database-name "{{ item.database }}" --database-user "{{ item.database }}"
|
||||||
|
--database-pass "{{ nextcloud_db_password }}" --database-host "{{ database_host }}"
|
||||||
|
--admin-user "{{ nextcloud_admin_user }}" --admin-pass "{{ nextcloud_admin_pw }}"
|
||||||
|
chdir: "{{ nextcloud_install_path }}"
|
||||||
|
become: true
|
||||||
|
become_user: "{{ item.user }}"
|
||||||
|
when: not nc_is_installed.stat.exists and item.database_type == "PostgreSQL"
|
||||||
|
|
Loading…
Reference in a new issue