Logging configuration.

This commit is contained in:
Andrea Dell'Amico 2021-08-11 16:44:06 +02:00
parent 4d46a7d4e9
commit b61d5e609e
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
3 changed files with 67 additions and 6 deletions

View File

@ -10,6 +10,9 @@ nextcloud_web_root: '{{ nextcloud_web_basedir }}/nextcloud'
nextcloud_data_base_dir: /srv
nextcloud_data_dir: '{{ nextcloud_data_base_dir }}/nextcloud/data'
nextcloud_oc_dir: '{{ nextcloud_data_base_dir }}/nextcloud/oc_keys'
nextcloud_log_directory: /var/log/nextcloud
nextcloud_log_backend: file
nextcloud_log_level: warning
nextcloud_servername: '{{ ansible_fqdn }}'
nextcloud_servernames:
- { webroot: '{{ nextcloud_web_root }}', id: 1, name: '{{ nextcloud_servername }}' }

View File

@ -9,10 +9,34 @@
- name: Create the nextcloud webroot
file: dest={{ nextcloud_web_basedir }} owner=root group=root state=directory
- name: Create the nextcloud data directory
file: dest={{ nextcloud_data_dir }} state=directory owner={{ item.user }} group={{ item.user }}
- name: Create the nextcloud log directory
file:
dest: '{{ nextcloud_log_directory }}'
state: directory
owner: '{{ item.user }}'
group: '{{ item.user }}'
with_items: '{{ phpfpm_pools }}'
- name: Create the nextcloud data directory
file:
dest: '{{ nextcloud_data_dir }}'
state: directory
owner: '{{ item.user }}'
group: '{{ item.user }}'
with_items: '{{ phpfpm_pools }}'
when: phpfpm_create_users
- name: Create the nextcloud data directory when the user has been created externally
become: True
become_user: '{{ item.user }}'
file:
dest: '{{ nextcloud_data_dir }}'
state: directory
owner: '{{ item.user }}'
group: '{{ item.user }}'
with_items: '{{ phpfpm_pools }}'
when: not phpfpm_create_users
- name: Get nextcloud
get_url: url={{ nextcloud_download_url }} dest=/srv/{{ nextcloud_dist_filename }}
@ -26,17 +50,35 @@
- block:
- name: Configure the nextcloud instance
shell: cd {{ item.doc_root }} ; php occ maintenance:install --database="{{ nextcloud_db }}" --database-host "{{ nextcloud_db_host }}" --database-name "{{ nextcloud_db_name }}" --database-user "{{ nextcloud_db_user }}" --database-pass "{{ nextcloud_db_pwd }}" --admin-user "{{ nextcloud_admin_user }}" --admin-pass "{{ nextcloud_admin_u_pwd }}" --data-dir={{ nextcloud_data_dir }} ; touch {{ nextcloud_data_dir }}/.ht_nextcloud_setup
shell: cd {{ item.doc_root }} && php occ maintenance:install --database="{{ nextcloud_db }}" --database-host "{{ nextcloud_db_host }}" --database-name "{{ nextcloud_db_name }}" --database-user "{{ nextcloud_db_user }}" --database-pass "{{ nextcloud_db_pwd }}" --admin-user "{{ nextcloud_admin_user }}" --admin-pass "{{ nextcloud_admin_u_pwd }}" --data-dir={{ nextcloud_data_dir }} && touch {{ nextcloud_data_dir }}/.ht_nextcloud_setup
args:
creates: '{{ nextcloud_data_dir }}/.ht_nextcloud_setup'
with_items: '{{ phpfpm_pools }}'
- name: Set the trusted domains list
shell: cd {{ item.webroot }} ; php occ config:system:set trusted_domains {{ item.id }} --value={{ item.name }} ; touch {{ nextcloud_data_dir }}/.ht_nextcloud_trusted_domains
shell: cd {{ item.webroot }} && php occ config:system:set trusted_domains {{ item.id }} --value={{ item.name }} && touch {{ nextcloud_data_dir }}/.ht_nextcloud_trusted_domains_{{ item.id }}
args:
creates: '{{ nextcloud_data_dir }}/.ht_nextcloud_trusted_domains'
creates: '{{ nextcloud_data_dir }}/.ht_nextcloud_trusted_domains_{{ item.id }}'
with_items: '{{ nextcloud_servernames }}'
- name: Set the log file path
shell: cd {{ item.doc_root }} && php occ log:file --file {{ nextcloud_log_directory }}/nextcloud.log && touch {{ nextcloud_data_dir }}/.ht_nextcloud_logfile
args:
creates: '{{ nextcloud_data_dir }}/.ht_nextcloud_logfile'
with_items: '{{ phpfpm_pools }}'
- name: Set the log level
shell: cd {{ item.doc_root }} && php occ log:manage --level {{ nextcloud_log_level }} && touch {{ nextcloud_data_dir }}/.ht_nextcloud_log_level
args:
creates: '{{ nextcloud_data_dir }}/.ht_nextcloud_log_level'
with_items: '{{ phpfpm_pools }}'
- name: Set the log backend
shell: cd {{ item.doc_root }} && php occ log:manage --backend {{ nextcloud_log_backend }} && touch {{ nextcloud_data_dir }}/.ht_nextcloud_log_backend
args:
creates: '{{ nextcloud_data_dir }}/.ht_nextcloud_log_backend'
with_items: '{{ phpfpm_pools }}'
- name: Setup the cron configuration
shell: cd {{ item.webroot }} ; php occ background:cron ; touch {{ nextcloud_data_dir }}/.ht_nextcloud_cron
args:
@ -64,8 +106,20 @@
- block:
- name: Create the nextcloud encryption keys directory
become_user: root
file: dest={{ nextcloud_oc_dir }} state=directory owner={{ item.user }} group={{ item.user }}
file:
dest: '{{ nextcloud_oc_dir }}'
state: directory
owner: '{{ item.user }}'
group: '{{ item.user }}'
with_items: '{{ phpfpm_pools }}'
when: phpfpm_create_users
- name: Create the nextcloud encryption keys directory when the user has been created externally
file:
dest: '{{ nextcloud_oc_dir }}'
state: directory
with_items: '{{ phpfpm_pools }}'
when: not phpfpm_create_users
- name: Activate global encryption
shell: cd {{ item.doc_root }} ; php occ app:enable encryption ; php occ encryption:enable ; php occ encryption:enable-master-key ; php occ encryption:change-key-storage-root {{ nextcloud_oc_dir }} ; touch {{ nextcloud_oc_dir }}/.ht_nextcloud_oc

View File

@ -20,10 +20,14 @@ nextcloud_php_required_packages:
- 'php{{ php_version }}-zip'
- 'php{{ php_version }}-bz2'
- 'php{{ php_version }}-gmp'
- 'php{{ php_version }}-redis'
- 'php{{ php_version }}-memcached'
- 'php{{ php_version }}-apcu'
- 'php-imagick'
- 'php-redis'
- 'php-apcu'
phpfpm_default_memory_limit: '{{ nextcloud_phpfpm_default_memory_limit }}'
nextcloud_php_global_settings:
- { option: 'always_populate_raw_post_data', value: '-1' }
- { option: 'allow_url_fopen', value: 'on' }