Compare commits
10 Commits
3cfec71334
...
450efd40b0
| Author | SHA1 | Date | |
|---|---|---|---|
| 450efd40b0 | |||
|
|
98f7291f5b | ||
|
|
297f8f7a41 | ||
|
|
5134c0c98c | ||
|
|
77eeeaa49f | ||
|
|
9df7216c3c | ||
|
|
1038079e44 | ||
| c6479b58d1 | |||
|
|
d19faae59d | ||
| f577ca9335 |
54
README.md
54
README.md
@@ -1 +1,53 @@
|
|||||||
# Nextcloud-Infra
|
# Nextcloud-Infra
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 🚀 Nextcloud Ansible Playbook
|
||||||
|
|
||||||
|
Automated deployment of **Nextcloud** with **Apache**, **MariaDB**, **PHP**, **Redis**, and **Let's Encrypt** on a Debian/Ubuntu server.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📦 Features
|
||||||
|
|
||||||
|
- Automatic local host detection and grouping
|
||||||
|
- Full Nextcloud installation with:
|
||||||
|
- Apache web server
|
||||||
|
- MariaDB database
|
||||||
|
- PHP + required extensions
|
||||||
|
- Redis and APCu caching
|
||||||
|
- HTTPS via Let's Encrypt
|
||||||
|
- Secure PHP and Apache configuration
|
||||||
|
- Database and admin user provisioning
|
||||||
|
- Cron jobs for background tasks and maintenance
|
||||||
|
- Trusted domain and regional settings
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🛠️ Requirements
|
||||||
|
|
||||||
|
- A Debian/Ubuntu server (tested on 20.04+)
|
||||||
|
- Python 3 and Ansible installed locally
|
||||||
|
- SSH access and sudo privileges
|
||||||
|
- DNS A-record pointing to your server IP
|
||||||
|
- **A `hosts` file with required variables** (see below)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📁 Inventory Setup (`hosts` file)
|
||||||
|
|
||||||
|
Create a file named `hosts` with:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[nextcloud]
|
||||||
|
|
||||||
|
[all:vars]
|
||||||
|
ansible_user=your-ssh-username
|
||||||
|
db_admin_user=nextcloud_db_admin
|
||||||
|
db_admin_password=secure_admin_password
|
||||||
|
nextcloud_db=nextcloud
|
||||||
|
nextcloud_db_user=nextcloud_user
|
||||||
|
nextcloud_db_password=secure_password
|
||||||
|
nextcloud_admin_user=admin
|
||||||
|
nextcloud_admin_password=admin_password
|
||||||
|
nextcloud_domain=cloud.example.com
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
state: directory
|
state: directory
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0777' # WORLD WRITABLE (alleen binnen container gebruikt)
|
mode: '0777'
|
||||||
|
|
||||||
- name: Start of update Collabora container
|
- name: Start of update Collabora container
|
||||||
docker_container:
|
docker_container:
|
||||||
@@ -63,7 +63,10 @@
|
|||||||
domain: "{{ collabora_domain | regex_replace('\\.', '\\\\.') }}"
|
domain: "{{ collabora_domain | regex_replace('\\.', '\\\\.') }}"
|
||||||
username: "{{ collabora_username }}"
|
username: "{{ collabora_username }}"
|
||||||
password: "{{ collabora_password }}"
|
password: "{{ collabora_password }}"
|
||||||
extra_params: --o:ssl.enable=false --o:ssl.termination=true --o:storage.wopi.host[0]={{ collabora_domain }}
|
command: >
|
||||||
|
--o:ssl.enable=false
|
||||||
|
--o:ssl.termination=true
|
||||||
|
--o:storage.wopi.host[0]={{ collabora_domain }}
|
||||||
|
|
||||||
- name: Maak tijdelijke Nginx-configuratie voor Certbot
|
- name: Maak tijdelijke Nginx-configuratie voor Certbot
|
||||||
copy:
|
copy:
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
vars:
|
|
||||||
domein_nextcloud: "{{ nextcloud_domain }}"
|
|
||||||
secret: "{{ secret }}"
|
|
||||||
|
|
||||||
- name: Install and configure Go, Docker, NATS, Janus, and Signaling Server
|
- name: Install and configure Go, Docker, NATS, Janus, and Signaling Server
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
vars:
|
||||||
|
domein_nextcloud: "{{ nextcloud_domain }}"
|
||||||
|
secret: "{{ secret }}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: Installeer python3-pip als dat nog niet aanwezig is
|
- name: Installeer python3-pip als dat nog niet aanwezig is
|
||||||
@@ -47,8 +47,7 @@ vars:
|
|||||||
git:
|
git:
|
||||||
repo: https://github.com/nextcloud/context_chat_backend.git
|
repo: https://github.com/nextcloud/context_chat_backend.git
|
||||||
dest: /opt/context_chat_backend
|
dest: /opt/context_chat_backend
|
||||||
#version: master # Pas aan als de branch anders heet, of laat weg om default te gebruiken
|
force: yes
|
||||||
force: yes # force checkout
|
|
||||||
|
|
||||||
- name: Kopieer voorbeeld .env naar .env
|
- name: Kopieer voorbeeld .env naar .env
|
||||||
copy:
|
copy:
|
||||||
|
|||||||
23
install_docker.yml
Normal file
23
install_docker.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
- name: Install Docker
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
become: true
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Installeer python3-pip als dat nog niet aanwezig is
|
||||||
|
apt:
|
||||||
|
name: python3-pip
|
||||||
|
state: present
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: Install Docker SDK for Python
|
||||||
|
pip:
|
||||||
|
name: docker
|
||||||
|
executable: pip3
|
||||||
|
|
||||||
|
- name: Install Docker
|
||||||
|
apt:
|
||||||
|
name: docker.io
|
||||||
|
state: present
|
||||||
|
update_cache: yes
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
become: true
|
become: true
|
||||||
vars:
|
vars:
|
||||||
ansible_python_interpreter: /usr/bin/python3
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
|
php_version: "8.3" # Gefixeerde versie - compatibel met Nextcloud
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Voeg ondubbelzinnig de laatste stabiele PHP PPA toe (voor recentste versies)
|
- name: Voeg ondubbelzinnig de laatste stabiele PHP PPA toe (voor recentste versies)
|
||||||
@@ -25,22 +26,22 @@
|
|||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
- name: Installeer benodigde pakketten
|
- name: Installeer benodigde pakketten met specifieke PHP-versie
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
- apache2
|
- apache2
|
||||||
- mariadb-server
|
- mariadb-server
|
||||||
- php
|
- "php{{ php_version }}"
|
||||||
- php-mysql
|
- "php{{ php_version }}-mysql"
|
||||||
- php-xml
|
- "php{{ php_version }}-xml"
|
||||||
- php-mbstring
|
- "php{{ php_version }}-mbstring"
|
||||||
- php-curl
|
- "php{{ php_version }}-curl"
|
||||||
- php-gd
|
- "php{{ php_version }}-gd"
|
||||||
- php-zip
|
- "php{{ php_version }}-zip"
|
||||||
- php-intl
|
- "php{{ php_version }}-intl"
|
||||||
- php-bcmath
|
- "php{{ php_version }}-bcmath"
|
||||||
- php-gmp
|
- "php{{ php_version }}-gmp"
|
||||||
- libapache2-mod-php
|
- "libapache2-mod-php{{ php_version }}"
|
||||||
- unzip
|
- unzip
|
||||||
- wget
|
- wget
|
||||||
- curl
|
- curl
|
||||||
@@ -50,17 +51,26 @@
|
|||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
- name: Detecteer actieve PHP-versie
|
- name: Deactiveer andere PHP-versies in Apache
|
||||||
shell: php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;'
|
shell: a2dismod php* || true
|
||||||
register: detected_php_version
|
|
||||||
retries: 5
|
|
||||||
delay: 3
|
|
||||||
until: detected_php_version.rc == 0
|
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
- name: Zet gedetecteerde PHP-versie als fact
|
- name: Activeer PHP {{ php_version }} module in Apache
|
||||||
set_fact:
|
shell: "a2enmod php{{ php_version }}"
|
||||||
php_version: "{{ detected_php_version.stdout }}"
|
register: php_mod_enabled
|
||||||
|
changed_when: "'enabled' in php_mod_enabled.stdout"
|
||||||
|
|
||||||
|
- name: Stel PHP {{ php_version }} in als standaard CLI-versie
|
||||||
|
community.general.alternatives:
|
||||||
|
name: php
|
||||||
|
path: "/usr/bin/php{{ php_version }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Fallback - stel PHP {{ php_version }} in als standaard via shell
|
||||||
|
shell: "update-alternatives --set php /usr/bin/php{{ php_version }}"
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
- name: Verhoog PHP-geheugenlimiet naar 512 MB
|
- name: Verhoog PHP-geheugenlimiet naar 512 MB
|
||||||
lineinfile:
|
lineinfile:
|
||||||
@@ -72,9 +82,8 @@
|
|||||||
- name: Verhoog OPcache interned_strings_buffer naar aanbevolen waarde
|
- name: Verhoog OPcache interned_strings_buffer naar aanbevolen waarde
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: "/etc/php/{{ php_version }}/apache2/php.ini"
|
path: "/etc/php/{{ php_version }}/apache2/php.ini"
|
||||||
regexp: '^opcache\.interned_strings_buffer\s*='
|
regexp: '^;?opcache\.interned_strings_buffer\s*='
|
||||||
line: 'opcache.interned_strings_buffer = 16'
|
line: 'opcache.interned_strings_buffer = 16'
|
||||||
insertafter: EOF
|
|
||||||
backup: yes
|
backup: yes
|
||||||
|
|
||||||
- name: Start Apache en MariaDB
|
- name: Start Apache en MariaDB
|
||||||
@@ -201,7 +210,7 @@
|
|||||||
|
|
||||||
- name: Installeer Nextcloud via OCC
|
- name: Installeer Nextcloud via OCC
|
||||||
shell: >
|
shell: >
|
||||||
sudo -u www-data php /var/www/nextcloud/occ maintenance:install
|
sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ maintenance:install
|
||||||
--database "mysql"
|
--database "mysql"
|
||||||
--database-name "{{ nextcloud_db }}"
|
--database-name "{{ nextcloud_db }}"
|
||||||
--database-user "{{ nextcloud_db_user }}"
|
--database-user "{{ nextcloud_db_user }}"
|
||||||
@@ -212,30 +221,39 @@
|
|||||||
creates: /var/www/nextcloud/config/config.php
|
creates: /var/www/nextcloud/config/config.php
|
||||||
chdir: /var/www/nextcloud
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
|
- name: Wacht tot Nextcloud config:system commando beschikbaar is
|
||||||
|
shell: "sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ list"
|
||||||
|
register: occ_list_output
|
||||||
|
retries: 5
|
||||||
|
delay: 10
|
||||||
|
until: "'config:system' in occ_list_output.stdout"
|
||||||
|
args:
|
||||||
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
- name: Voeg domein toe aan trusted_domains
|
- name: Voeg domein toe aan trusted_domains
|
||||||
shell: >
|
shell: >
|
||||||
sudo -u www-data php /var/www/nextcloud/occ config:system:set trusted_domains 1
|
sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ config:system:set trusted_domains 1
|
||||||
--value="{{ nextcloud_domain }}"
|
--value="{{ nextcloud_domain }}"
|
||||||
args:
|
args:
|
||||||
chdir: /var/www/nextcloud
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
- name: Voer mimetype migraties uit via occ
|
- name: Voer mimetype migraties uit via occ
|
||||||
shell: sudo -u www-data php /var/www/nextcloud/occ maintenance:repair --include-expensive
|
shell: "sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ maintenance:repair --include-expensive"
|
||||||
args:
|
args:
|
||||||
chdir: /var/www/nextcloud
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
- name: Repareer ontbrekende theming-cachebestanden
|
- name: Repareer ontbrekende theming-cachebestanden
|
||||||
shell: sudo -u www-data php /var/www/nextcloud/occ maintenance:repair
|
shell: "sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ maintenance:repair"
|
||||||
args:
|
args:
|
||||||
chdir: /var/www/nextcloud
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
- name: Registreer theming-app expliciet opnieuw
|
- name: Registreer theming-app expliciet opnieuw
|
||||||
shell: sudo -u www-data php /var/www/nextcloud/occ app:enable theming
|
shell: "sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ app:enable theming"
|
||||||
args:
|
args:
|
||||||
chdir: /var/www/nextcloud
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
- name: Stel Nextcloud in om cron als achtergrondproces te gebruiken
|
- name: Stel Nextcloud in om cron als achtergrondproces te gebruiken
|
||||||
shell: sudo -u www-data php /var/www/nextcloud/occ background:cron
|
shell: "sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ background:cron"
|
||||||
args:
|
args:
|
||||||
chdir: /var/www/nextcloud
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
@@ -244,7 +262,7 @@
|
|||||||
name: "Nextcloud background jobs"
|
name: "Nextcloud background jobs"
|
||||||
user: www-data
|
user: www-data
|
||||||
minute: "*/5"
|
minute: "*/5"
|
||||||
job: "php -f /var/www/nextcloud/cron.php"
|
job: "php{{ php_version }} -f /var/www/nextcloud/cron.php"
|
||||||
|
|
||||||
- name: Voeg cronjob toe voor Nextcloud logrotatie (dagelijks)
|
- name: Voeg cronjob toe voor Nextcloud logrotatie (dagelijks)
|
||||||
cron:
|
cron:
|
||||||
@@ -252,7 +270,7 @@
|
|||||||
user: www-data
|
user: www-data
|
||||||
minute: "0"
|
minute: "0"
|
||||||
hour: "2"
|
hour: "2"
|
||||||
job: "php /var/www/nextcloud/occ log:manage --shrink --days=14"
|
job: "php{{ php_version }} /var/www/nextcloud/occ log:manage --shrink --days=14"
|
||||||
cron_file: nextcloud_logrotate
|
cron_file: nextcloud_logrotate
|
||||||
|
|
||||||
- name: Voeg cronjob toe voor OCC onderhoud (elke zondag)
|
- name: Voeg cronjob toe voor OCC onderhoud (elke zondag)
|
||||||
@@ -262,7 +280,7 @@
|
|||||||
minute: "30"
|
minute: "30"
|
||||||
hour: "3"
|
hour: "3"
|
||||||
weekday: "0"
|
weekday: "0"
|
||||||
job: "php /var/www/nextcloud/occ maintenance:repair && php /var/www/nextcloud/occ files:scan-app-data"
|
job: "php{{ php_version }} /var/www/nextcloud/occ maintenance:repair && php{{ php_version }} /var/www/nextcloud/occ files:scan-app-data"
|
||||||
cron_file: nextcloud_maintenance
|
cron_file: nextcloud_maintenance
|
||||||
|
|
||||||
- name: Voeg cronjob toe voor mimetype repair (1× per week)
|
- name: Voeg cronjob toe voor mimetype repair (1× per week)
|
||||||
@@ -272,18 +290,18 @@
|
|||||||
minute: "0"
|
minute: "0"
|
||||||
hour: "4"
|
hour: "4"
|
||||||
weekday: "0"
|
weekday: "0"
|
||||||
job: "php /var/www/nextcloud/occ maintenance:repair --include-expensive"
|
job: "php{{ php_version }} /var/www/nextcloud/occ maintenance:repair --include-expensive"
|
||||||
cron_file: nextcloud_mimetype_repair
|
cron_file: nextcloud_mimetype_repair
|
||||||
|
|
||||||
- name: Stel onderhoudsvenster in op 03:00 (Nextcloud background tasks)
|
- name: Stel onderhoudsvenster in op 03:00 (Nextcloud background tasks)
|
||||||
shell: >
|
shell: >
|
||||||
sudo -u www-data php /var/www/nextcloud/occ config:system:set maintenance_window_start --value="3"
|
sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ config:system:set maintenance_window_start --value="3"
|
||||||
args:
|
args:
|
||||||
chdir: /var/www/nextcloud
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
- name: Stel standaard telefoonregio in (bijv. NL)
|
- name: Stel standaard telefoonregio in (bijv. NL)
|
||||||
shell: >
|
shell: >
|
||||||
sudo -u www-data php /var/www/nextcloud/occ config:system:set default_phone_region --value="NL"
|
sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ config:system:set default_phone_region --value="NL"
|
||||||
args:
|
args:
|
||||||
chdir: /var/www/nextcloud
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
@@ -304,7 +322,7 @@
|
|||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
notify: Herstart Apache
|
notify: Herstart Apache
|
||||||
|
|
||||||
- name: Installeer php{{ php_version }}-redis
|
- name: Installeer php{{ php_version }}-redis
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
@@ -322,11 +340,11 @@
|
|||||||
|
|
||||||
- name: Installeer php-imagick extensie
|
- name: Installeer php-imagick extensie
|
||||||
apt:
|
apt:
|
||||||
name: php-imagick
|
name: "php{{ php_version }}-imagick"
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
notify: Herstart Apache
|
notify: Herstart Apache
|
||||||
|
|
||||||
- name: Installeer ImageMagick en SVG-ondersteuning
|
- name: Installeer ImageMagick en SVG-ondersteuning
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
@@ -339,17 +357,16 @@
|
|||||||
|
|
||||||
- name: Stel memcache in (APCu) voor Nextcloud
|
- name: Stel memcache in (APCu) voor Nextcloud
|
||||||
shell: >
|
shell: >
|
||||||
sudo -u www-data php /var/www/nextcloud/occ config:system:set memcache.local --value="\\OC\\Memcache\\APCu" --type=string
|
sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ config:system:set memcache.local --value="\\OC\\Memcache\\APCu" --type=string
|
||||||
args:
|
args:
|
||||||
chdir: /var/www/nextcloud
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
- name: Stel memcache locking in (Redis) voor Nextcloud
|
- name: Stel memcache locking in (Redis) voor Nextcloud
|
||||||
shell: >
|
shell: >
|
||||||
sudo -u www-data php /var/www/nextcloud/occ config:system:set memcache.locking --value="\\OC\\Memcache\\Redis" --type=string
|
sudo -u www-data php{{ php_version }} /var/www/nextcloud/occ config:system:set memcache.locking --value="\\OC\\Memcache\\Redis" --type=string
|
||||||
args:
|
args:
|
||||||
chdir: /var/www/nextcloud
|
chdir: /var/www/nextcloud
|
||||||
|
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
- name: Herstart Apache
|
- name: Herstart Apache
|
||||||
systemd:
|
systemd:
|
||||||
|
|||||||
233
install_whiteboard.yml
Normal file
233
install_whiteboard.yml
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
- name: Voeg lokale host toe aan nextcloud groep
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: yes
|
||||||
|
tasks:
|
||||||
|
- name: Haal IP-adres op van huidige server
|
||||||
|
debug:
|
||||||
|
var: ansible_default_ipv4.address
|
||||||
|
|
||||||
|
- name: Voeg IP-adres toe aan 'nextcloud' groep
|
||||||
|
add_host:
|
||||||
|
name: "{{ ansible_default_ipv4.address }}"
|
||||||
|
groups: nextcloud
|
||||||
|
ansible_user: "{{ ansible_user }}"
|
||||||
|
|
||||||
|
- name: Setup Whiteboard server with Docker Compose v2, HTTPS/WSS, WebSocket fix, and healthcheck
|
||||||
|
hosts: whiteboard
|
||||||
|
become: true
|
||||||
|
vars:
|
||||||
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Update and upgrade apt packages
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
upgrade: dist
|
||||||
|
|
||||||
|
- name: Install required packages
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- apt-transport-https
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
- software-properties-common
|
||||||
|
- jq
|
||||||
|
- netcat
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add NodeSource Node.js 20.x repository
|
||||||
|
shell: curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
|
||||||
|
- name: Install Node.js and npm (from NodeSource)
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- nodejs
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add Docker GPG key
|
||||||
|
apt_key:
|
||||||
|
url: https://download.docker.com/linux/ubuntu/gpg
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add Docker repository
|
||||||
|
apt_repository:
|
||||||
|
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install Docker and Docker Compose v2
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure Docker Compose v2 plugin is present
|
||||||
|
command: docker compose version
|
||||||
|
register: docker_compose_version
|
||||||
|
failed_when: docker_compose_version.rc != 0
|
||||||
|
|
||||||
|
- name: Clone Whiteboard repository (force overwrite)
|
||||||
|
git:
|
||||||
|
repo: https://github.com/nextcloud/whiteboard.git
|
||||||
|
dest: /opt/whiteboard
|
||||||
|
version: main
|
||||||
|
force: yes
|
||||||
|
|
||||||
|
- name: Install npm packages (including dotenv)
|
||||||
|
command: npm install
|
||||||
|
args:
|
||||||
|
chdir: /opt/whiteboard
|
||||||
|
|
||||||
|
- name: Create updated .env file for Whiteboard (matching Docker expectations)
|
||||||
|
copy:
|
||||||
|
dest: /opt/whiteboard/.env
|
||||||
|
content: |
|
||||||
|
NEXTCLOUD_URL={{ nc_url }}
|
||||||
|
NEXTCLOUD_USER={{ nc_user }}
|
||||||
|
NEXTCLOUD_PASSWORD={{ nc_password }}
|
||||||
|
JWT_SECRET_KEY={{ jwt_secret }}
|
||||||
|
FORCE_HTTPS=true
|
||||||
|
TRUST_PROXY=true
|
||||||
|
PORT=3002
|
||||||
|
|
||||||
|
- name: Update docker-compose.yml to use env_file
|
||||||
|
copy:
|
||||||
|
dest: /opt/whiteboard/docker-compose.yml
|
||||||
|
content: |
|
||||||
|
version: '3.7'
|
||||||
|
services:
|
||||||
|
nextcloud-whiteboard-server:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- 3002:3002
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
|
||||||
|
- name: Run Docker Compose up
|
||||||
|
command: docker compose up -d
|
||||||
|
args:
|
||||||
|
chdir: /opt/whiteboard
|
||||||
|
|
||||||
|
- name: Install Nginx and Certbot
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- nginx
|
||||||
|
- certbot
|
||||||
|
- python3-certbot-nginx
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure nginx.conf has map for connection_upgrade
|
||||||
|
blockinfile:
|
||||||
|
path: /etc/nginx/nginx.conf
|
||||||
|
block: |
|
||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
insertafter: '^http {'
|
||||||
|
marker: "# {mark} ANSIBLE MANAGED CONNECTION UPGRADE MAP"
|
||||||
|
|
||||||
|
- name: Temporary Nginx HTTP config for certificate request
|
||||||
|
copy:
|
||||||
|
dest: /etc/nginx/sites-available/whiteboard
|
||||||
|
content: |
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name {{ domain }};
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:3002;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header X-Forwarded-Port 80;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Enable Nginx site and disable default
|
||||||
|
file:
|
||||||
|
src: /etc/nginx/sites-available/whiteboard
|
||||||
|
dest: /etc/nginx/sites-enabled/whiteboard
|
||||||
|
state: link
|
||||||
|
force: true
|
||||||
|
|
||||||
|
- name: Remove default Nginx site
|
||||||
|
file:
|
||||||
|
path: /etc/nginx/sites-enabled/default
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Test Nginx configuration
|
||||||
|
command: nginx -t
|
||||||
|
|
||||||
|
- name: Reload Nginx
|
||||||
|
systemd:
|
||||||
|
name: nginx
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
- name: Obtain Let’s Encrypt certificate
|
||||||
|
command: >
|
||||||
|
certbot --nginx -d {{ domain }} --non-interactive --agree-tos -m {{ email }}
|
||||||
|
|
||||||
|
- name: Replace Nginx config with SSL, WebSocket fix, and healthcheck support
|
||||||
|
copy:
|
||||||
|
dest: /etc/nginx/sites-available/whiteboard
|
||||||
|
content: |
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name {{ domain }};
|
||||||
|
location / {
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name {{ domain }};
|
||||||
|
|
||||||
|
ssl_certificate /etc/letsencrypt/live/{{ domain }}/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/{{ domain }}/privkey.pem;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:3002;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header X-Forwarded-Port 443;
|
||||||
|
proxy_read_timeout 86400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Test final Nginx configuration
|
||||||
|
command: nginx -t
|
||||||
|
|
||||||
|
- name: Reload Nginx with final SSL config
|
||||||
|
systemd:
|
||||||
|
name: nginx
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
- name: Restart Docker Compose services
|
||||||
|
command: docker compose restart
|
||||||
|
args:
|
||||||
|
chdir: /opt/whiteboard
|
||||||
|
|
||||||
|
- name: Check if backend port 3002 is open
|
||||||
|
command: nc -zv localhost 3002
|
||||||
|
register: portcheck_result
|
||||||
|
failed_when: portcheck_result.rc != 0
|
||||||
|
|
||||||
|
- name: Show port 3002 check result
|
||||||
|
debug:
|
||||||
|
var: portcheck_result
|
||||||
Reference in New Issue
Block a user