swcc.ansible_nextcloud
Nextcloud Ansible Role
This Ansible role installs Nextcloud from nextcloud.com. It is designed to work with PHP-FPM
, so it also installs the necessary PHP-FPM role as a dependency (NBZ4live.php-fpm
).
Example Playbook
Here’s a simple example of an Ansible playbook:
- hosts: webservers
roles:
- role: swcc.nextcloud
nextcloud_destination: /home/nextcloud
nextcloud_version: 19.0.3
Role Parameters
Variable | Default | Type | Description |
---|---|---|---|
nextcloud_version |
20.0.2 |
string |
The version of Nextcloud to install |
nextcloud_destination |
/var/www |
string |
The installation location for Nextcloud (it will be in the {{ nextcloud_destination}}/nextcloud/ directory) |
nextcloud_dir_user |
www-data |
string |
The Unix user who will own the installed directory |
nextcloud_dir_group |
www-data |
string |
The Unix group that will own the installed directory |
nextcloud_php_memory_limit |
512M |
string |
PHP memory limit setting. The recommended default by Nextcloud is 512M. |
nextcloud_config |
{} |
dict |
A dictionary of key values to use in the config/config.php file. Ensure values are valid PHP. For example, a string should be specified in Ansible as "'mystring'" to appear as 'mystring' in the config.php file. |
nextcloud_onlyoffice_force_flush_period |
undefined | string |
A setting to regularly save OnlyOffice changes to disk. For example, 300s to save every 5 minutes. |
Optional Backup Variables
Variable | Default | Type | Description |
---|---|---|---|
nextcloud_backup |
- | object |
Set up this object for backing up both your database and Nextcloud data. |
nextcloud_backup.destination_server |
- | string |
Backup server that will receive all files (using rsync ) |
nextcloud_backup.retention |
7 |
number |
Number of days to keep database backups on the server |
nextcloud_backup.directory |
nextcloud_destination + '/nextcloud/data' |
string |
Path to the Nextcloud data directory to back up |
nextcloud_backup.pg |
- | object |
Connection information for the database. See below for details. |
nextcloud_backup.pg.pg_dump_binary |
- | string |
Path to the pg_dump binary on the server |
nextcloud_backup.pg.host |
localhost |
string |
Hostname of the PostgreSQL database |
nextcloud_backup.pg.port |
5432 |
string |
Port number for the PostgreSQL database |
nextcloud_backup.pg.dbname |
nextcloud |
string |
Name of the PostgreSQL database |
nextcloud_backup.pg.username |
nextcloud |
string |
User for the PostgreSQL database |
nextcloud_backup.pg.password |
- | string |
Password for the PostgreSQL database |
⚠️ Before using this role, make sure to check the PHP-FPM variables of the dependent php-fpm Ansible role. ⚠️
Also, check the PHP version you want to run by setting the php_fpm_version
variable. Here’s an example configuration for the PHP-FPM role that should cater to most needs:
php_fpm_version: 7.4
php_fpm_pool_defaults:
pm: dynamic
pm.max_children: 10
pm.start_servers: 2
pm.min_spare_servers: 1
pm.max_spare_servers: 4
php_fpm_pools:
- name: www
user: www-data
group: www-data
listen: "/run/php/php{{ php_fpm_version }}-fpm.sock"
listen.owner: www-data
listen.group: www-data
chdir: /var/www
env:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
TMPDIR: "/tmp"
TMP: "/tmp"
HOSTNAME: "$HOSTNAME"
Makefile for Easier Ansible Use
I've created a simple Makefile to make your Ansible runs easier. Feel free to check it out.
Download the *.deb
package from the GitHub releases, install it, and start using it with ansible-make help
.
License
GPLv3