ansible/roles/nextcloud/tasks/main.yml

89 lines
2.6 KiB
YAML

---
- name: Enable sury php apt-key
apt_key: url="https://packages.sury.org/php/apt.gpg"
- name: Enable sury php repository
apt_repository: repo="deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main"
- name: Enable collaboraoffice apt-key
apt_key: url="https://collaboraoffice.com/downloads/gpg/collaboraonline-release-keyring.gpg"
- name: Enable collaboraoffice repository
apt_repository: repo="deb https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-debian11 ./"
- name: Install packages
apt:
name:
- php-redis
- php8.0
- php8.0-apcu
- php8.0-bcmath
- php8.0-bz2
- php8.0-cli
- php8.0-common
- php8.0-curl
- php8.0-dev
- php8.0-fpm
- php8.0-gd
- php8.0-gmp
- php8.0-imap
- php8.0-intl
- php8.0-ldap
- php8.0-mbstring
- php8.0-mysql
- php8.0-opcache
- php8.0-pgsql
- php8.0-readline
- php8.0-soap
- php8.0-sqlite3
- php8.0-tidy
- php8.0-xml
- php8.0-xmlrpc
- php8.0-zip
- postgresql
- python3-psycopg2
- name: Configure PostgreSQL database
postgresql_db: name={{ nextcloud_dbname }}
become: true
become_user: postgres
- name: Configure PostgreSQL user
postgresql_user: db={{ nextcloud_dbname }} name={{ nextcloud_dbuser }} password={{ nextcloud_dbpass }} priv=ALL state=present
become: true
become_user: postgres
- name: Ensure certificates are available
command: openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/nginx/ssl/{{ nextcloud_domain }}.key -out /etc/nginx/ssl/{{ nextcloud_domain }}.crt -days 730 -subj "/CN={{ nextcloud_domain }}" creates=/etc/nginx/ssl/{{ nextcloud_domain }}.crt
notify: Restart nginx
- name: Configure certificate manager for nextcloud
template: src=certs.j2 dest=/etc/acertmgr/{{ nextcloud_domain }}.conf
notify: Run acertmgr
- name: Create vhost directory
file: path=/var/www/nextcloud state=directory owner=www-data group=www-data
- name: Configure vhost
template: src=vhost.j2 dest=/etc/nginx/sites-available/nextcloud
notify: Restart nginx
- name: Configure php8.0-fpm
copy: src=www.conf dest=/etc/php/8.0/fpm/pool.d/www.conf
notify: Restart php8.0-fpm
- name: Configure php8.0 opcache
copy: src=opcache.ini dest=/etc/php/8.0/mods-available/opcache.ini
notify: Restart php8.0-fpm
- name: Enable vhost
file: src=/etc/nginx/sites-available/nextcloud dest=/etc/nginx/sites-enabled/nextcloud state=link
notify: Restart nginx
- name: Start php8.0-fpm
service: name=php8.0-fpm state=started enabled=yes
- name: Start PostgreSQL
service: name=postgresql state=started enabled=yes