add postgres compatibility
This commit is contained in:
parent
10c93e1916
commit
91afd99167
@ -4,14 +4,17 @@ nextcloud_db_name: nextcloud
|
|||||||
nextcloud_SQl_target_file:
|
nextcloud_SQl_target_file:
|
||||||
nextcloud_db_user: nextcloud
|
nextcloud_db_user: nextcloud
|
||||||
nextcloud_db_password:
|
nextcloud_db_password:
|
||||||
|
nextcloud_dbhost: localhost
|
||||||
|
nextcloud_dbport:
|
||||||
|
nextcloud_DB_type: postgres # mysql or postgres
|
||||||
nextcloud_admin_user: admin
|
nextcloud_admin_user: admin
|
||||||
nextcloud_admin_password:
|
nextcloud_admin_password:
|
||||||
nextcloud_datadirectory: /var/nextcloud
|
nextcloud_datadirectory: /var/nextcloud
|
||||||
nextcloud_web_root: /usr/share/webapps/nextcloud
|
nextcloud_web_root: /usr/share/webapps/nextcloud
|
||||||
nextcloud_trusted_domains:
|
nextcloud_trusted_domains:
|
||||||
- localhost
|
- localhost
|
||||||
nextcloud_dbhost: localhost
|
|
||||||
nextcloud_dbport:
|
|
||||||
|
|
||||||
nextcloud_config_options: # additional options to set in config.php
|
nextcloud_config_options: # additional options to set in config.php
|
||||||
- option: overwrite.cli.url
|
- option: overwrite.cli.url
|
||||||
|
@ -48,7 +48,6 @@ galaxy_info:
|
|||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- {role: nginx,become: yes}
|
- {role: nginx,become: yes}
|
||||||
- {role: mariadb,become: yes}
|
|
||||||
- php
|
- php
|
||||||
- cronie
|
- cronie
|
||||||
- fail2ban
|
- fail2ban
|
||||||
|
27
tasks/database_mysql.yml
Normal file
27
tasks/database_mysql.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
- name: "Ensure database is present"
|
||||||
|
become: yes
|
||||||
|
mysql_db:
|
||||||
|
name: "{{ nextcloud_db_name }}"
|
||||||
|
collation: utf8mb4_unicode_ci
|
||||||
|
encoding: utf8mb4
|
||||||
|
state: present
|
||||||
|
register: nextcloud_database_creation
|
||||||
|
|
||||||
|
- name: import DATA in database in case of creation
|
||||||
|
become: yes
|
||||||
|
mysql_db:
|
||||||
|
name: "{{ nextcloud_db_name }}"
|
||||||
|
state: import
|
||||||
|
target: "{{gitea_SQl_target_file}}"
|
||||||
|
register: nextcloud_database_import
|
||||||
|
when: nextcloud_database_creation.changed == true and nextcloud_SQl_target_file is defined
|
||||||
|
|
||||||
|
- name: "Ensure db user is present"
|
||||||
|
become: yes
|
||||||
|
mysql_user:
|
||||||
|
name: "{{ nextcloud_db_user }}"
|
||||||
|
host: localhost
|
||||||
|
password: "{{ nextcloud_db_password }}"
|
||||||
|
priv: "{{ nextcloud_db_name }}.*:ALL"
|
||||||
|
state: present
|
29
tasks/database_postgres.yml
Normal file
29
tasks/database_postgres.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
- name: "Ensure db user is present"
|
||||||
|
become: yes
|
||||||
|
become_user: postgres
|
||||||
|
postgresql_user:
|
||||||
|
name: "{{ nextcloud_db_user }}"
|
||||||
|
password: "{{ nextcloud_db_password }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: "Ensure database is present"
|
||||||
|
become: yes
|
||||||
|
become_user: postgres
|
||||||
|
postgresql_db:
|
||||||
|
name: "{{ nextcloud_db_name }}"
|
||||||
|
lc_collate: fr_FR.UTF-8
|
||||||
|
encoding: utf8
|
||||||
|
owner: "{{ nextcloud_db_user }}"
|
||||||
|
state: present
|
||||||
|
register: nextcloud_database_creation
|
||||||
|
|
||||||
|
|
||||||
|
- name: import DATA in database in case of creation
|
||||||
|
become: yes
|
||||||
|
become_user: postgres
|
||||||
|
postgresql_db:
|
||||||
|
name: "{{ nextcloud_db_name }}"
|
||||||
|
state: restore
|
||||||
|
target: "{{ nextcloud_SQl_target_file }}"
|
||||||
|
register: nextcloud_database_import
|
||||||
|
when: nextcloud_database_creation.changed == true and nextcloud_SQl_target_file is defined
|
@ -1,31 +1,8 @@
|
|||||||
---
|
---
|
||||||
# tasks file for nextcloud
|
# tasks file for nextcloud
|
||||||
|
|
||||||
- name: "Ensure database is present"
|
- name: select specific Database tasks
|
||||||
become: yes
|
include_tasks: "database_{{nextcloud_DB_type}}.yml"
|
||||||
mysql_db:
|
|
||||||
name: "{{ nextcloud_db_name }}"
|
|
||||||
collation: utf8mb4_unicode_ci
|
|
||||||
encoding: utf8mb4
|
|
||||||
state: present
|
|
||||||
register: nextcloud_database_creation
|
|
||||||
|
|
||||||
- name: import DATA in database in case of creation
|
|
||||||
become: yes
|
|
||||||
mysql_db:
|
|
||||||
name: "{{ nextcloud_db_name }}"
|
|
||||||
state: import
|
|
||||||
target: "{{gitea_SQl_target_file}}"
|
|
||||||
when: nextcloud_database_creation.changed == true and nextcloud_SQl_target_file is defined
|
|
||||||
|
|
||||||
- name: "Ensure db user is present"
|
|
||||||
become: yes
|
|
||||||
mysql_user:
|
|
||||||
name: "{{ nextcloud_db_user }}"
|
|
||||||
host: localhost
|
|
||||||
password: "{{ nextcloud_db_password }}"
|
|
||||||
priv: "{{ nextcloud_db_name }}.*:ALL"
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: ensure pacman hook folder exist
|
- name: ensure pacman hook folder exist
|
||||||
become: true
|
become: true
|
||||||
@ -77,9 +54,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
- name: installation - ensure nextcloud installation is finished
|
- name: installation - ensure nextcloud config
|
||||||
command: >
|
command: >
|
||||||
php {{ nextcloud_web_root }}/occ maintenance:install --database "mysql" --database-name "{{ nextcloud_db_name}}"
|
php {{ nextcloud_web_root }}/occ maintenance:install --database "{{ 'pgsql' if nextcloud_DB_type == 'postgres' else nextcloud_DB_type }}" --database-name "{{ nextcloud_db_name}}"
|
||||||
--database-user "{{ nextcloud_db_user }}" --database-pass "{{ nextcloud_db_password }}"
|
--database-user "{{ nextcloud_db_user }}" --database-pass "{{ nextcloud_db_password }}"
|
||||||
--admin-user "{{ nextcloud_admin_user }}" --admin-pass "{{ nextcloud_admin_password }}" --data-dir "{{ nextcloud_datadirectory }}"
|
--admin-user "{{ nextcloud_admin_user }}" --admin-pass "{{ nextcloud_admin_password }}" --data-dir "{{ nextcloud_datadirectory }}"
|
||||||
become: true
|
become: true
|
||||||
@ -87,6 +64,7 @@
|
|||||||
changed_when: true
|
changed_when: true
|
||||||
when: installed_mode is changed or nextcloud_config_exist.stat.exists == false
|
when: installed_mode is changed or nextcloud_config_exist.stat.exists == false
|
||||||
|
|
||||||
|
|
||||||
- name: installation - ensure trusted domains are set
|
- name: installation - ensure trusted domains are set
|
||||||
command: 'php {{ nextcloud_web_root }}/occ config:system:set trusted_domains {{ item.0 }} --value "{{ item.1 }}"'
|
command: 'php {{ nextcloud_web_root }}/occ config:system:set trusted_domains {{ item.0 }} --value "{{ item.1 }}"'
|
||||||
become: true
|
become: true
|
||||||
@ -95,6 +73,16 @@
|
|||||||
with_indexed_items:
|
with_indexed_items:
|
||||||
- '{{ nextcloud_trusted_domains }}'
|
- '{{ nextcloud_trusted_domains }}'
|
||||||
|
|
||||||
|
- name: ensure correct database parameter in config.php
|
||||||
|
become: true
|
||||||
|
lineinfile:
|
||||||
|
path: '{{ nextcloud_web_root }}/config/config.php'
|
||||||
|
regexp: '^\s*''{{ item.option }}'''
|
||||||
|
line: ' ''{{ item.option }}'' => {{ item.value }},'
|
||||||
|
insertafter: '\$CONFIG'
|
||||||
|
with_items: '{{ nextcloud_db_options }}'
|
||||||
|
when: nextcloud_config_options is defined
|
||||||
|
|
||||||
- name: ensure additional options are set in config.php if defined
|
- name: ensure additional options are set in config.php if defined
|
||||||
become: true
|
become: true
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
@ -1,2 +1,16 @@
|
|||||||
---
|
---
|
||||||
# vars file for nextcloud
|
# vars file for nextcloud
|
||||||
|
|
||||||
|
nextcloud_db_options:
|
||||||
|
- option: dbtype
|
||||||
|
value: "{{ 'pgsql' if nextcloud_DB_type == 'postgres' else nextcloud_DB_type }}"
|
||||||
|
- option: dbname
|
||||||
|
value: "{{nextcloud_db_name}}"
|
||||||
|
- option: dbuser
|
||||||
|
value: "{{nextcloud_db_user}}"
|
||||||
|
- option: dbpassword
|
||||||
|
value: "{{nextcloud_db_password}}"
|
||||||
|
- option: dbhost
|
||||||
|
value: "{{nextcloud_dbhost}}"
|
||||||
|
- option: dbport
|
||||||
|
value: "{{nextcloud_dbport}}"
|
Loading…
Reference in New Issue
Block a user