Major architectural changes: - Replace config file templating with unified OCC command script - Remove custom_apps mount overlay that caused Caddy serving issues - Implement script-based configuration for idempotency and clarity Configuration improvements: - Add email/SMTP support with master switch (nextcloud_email_enabled) - Add OIDC/SSO integration with Authentik support - Add apps installation (user_oidc, calendar, contacts) - Enable group provisioning and quota management from OIDC - Set nextcloud_oidc_unique_uid to false per Authentik docs Files removed: - nextcloud.config.php.j2 (replaced by OCC commands) - redis.config.php.j2 (replaced by OCC commands) - optimization.yml (merged into configure.yml) Files added: - configure-nextcloud.sh.j2 (single source of truth for config) - configure.yml (deploys and runs configuration script) Documentation: - Add comprehensive OIDC setup guide with Authentik integration - Document custom scope mapping and group provisioning - Add email configuration examples for common providers - Update vault variables documentation - Explain two-phase deployment approach Host configuration: - Change admin user from 'admin' to 'joakim' - Add admin email configuration
204 lines
5.6 KiB
YAML
204 lines
5.6 KiB
YAML
---
|
|
# =================================================================
|
|
# Nextcloud Removal Playbook
|
|
# =================================================================
|
|
# Rick-Infra - Clean removal of Nextcloud installation
|
|
#
|
|
# This playbook removes all Nextcloud components:
|
|
# - Systemd services and timers
|
|
# - Container and images
|
|
# - Data directories
|
|
# - Database and user
|
|
# - Caddy configuration
|
|
# - System user and groups
|
|
#
|
|
# Usage: ansible-playbook playbooks/remove-nextcloud.yml -i inventory/hosts.yml
|
|
|
|
- name: Remove Nextcloud Installation
|
|
hosts: arch-vps
|
|
become: yes
|
|
gather_facts: yes
|
|
|
|
vars:
|
|
nextcloud_user: nextcloud
|
|
nextcloud_group: nextcloud
|
|
nextcloud_home: /opt/nextcloud
|
|
nextcloud_db_name: nextcloud
|
|
nextcloud_db_user: nextcloud
|
|
caddy_sites_enabled_dir: /etc/caddy/sites-enabled
|
|
|
|
tasks:
|
|
# ============================================
|
|
# Stop and Disable Services
|
|
# ============================================
|
|
|
|
- name: Stop and disable nextcloud-cron timer
|
|
systemd:
|
|
name: nextcloud-cron.timer
|
|
state: stopped
|
|
enabled: no
|
|
failed_when: false
|
|
|
|
- name: Stop and disable nextcloud-cron service
|
|
systemd:
|
|
name: nextcloud-cron.service
|
|
state: stopped
|
|
enabled: no
|
|
failed_when: false
|
|
|
|
- name: Stop and disable nextcloud service
|
|
systemd:
|
|
name: nextcloud.service
|
|
state: stopped
|
|
enabled: no
|
|
failed_when: false
|
|
|
|
# ============================================
|
|
# Remove Container and Images
|
|
# ============================================
|
|
|
|
- name: Remove nextcloud container (if running)
|
|
command: podman rm -f nextcloud
|
|
register: container_remove
|
|
changed_when: container_remove.rc == 0
|
|
failed_when: false
|
|
|
|
# ============================================
|
|
# Remove Systemd Units
|
|
# ============================================
|
|
|
|
- name: Remove nextcloud-cron systemd units
|
|
file:
|
|
path: "{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- /etc/systemd/system/nextcloud-cron.timer
|
|
- /etc/systemd/system/nextcloud-cron.service
|
|
|
|
- name: Remove nextcloud quadlet file
|
|
file:
|
|
path: /etc/containers/systemd/nextcloud.container
|
|
state: absent
|
|
|
|
- name: Reload systemd daemon
|
|
systemd:
|
|
daemon_reload: yes
|
|
|
|
# ============================================
|
|
# Remove Database
|
|
# ============================================
|
|
|
|
- name: Drop nextcloud database
|
|
become_user: postgres
|
|
postgresql_db:
|
|
name: "{{ nextcloud_db_name }}"
|
|
state: absent
|
|
failed_when: false
|
|
|
|
- name: Drop nextcloud database user
|
|
become_user: postgres
|
|
postgresql_user:
|
|
name: "{{ nextcloud_db_user }}"
|
|
state: absent
|
|
failed_when: false
|
|
|
|
# ============================================
|
|
# Remove Caddy Configuration
|
|
# ============================================
|
|
|
|
- name: Remove nextcloud Caddy configuration
|
|
file:
|
|
path: "{{ caddy_sites_enabled_dir }}/nextcloud.caddy"
|
|
state: absent
|
|
notify: reload caddy
|
|
|
|
# ============================================
|
|
# Remove Data Directories
|
|
# ============================================
|
|
|
|
- name: Remove nextcloud home directory (including all data)
|
|
file:
|
|
path: "{{ nextcloud_home }}"
|
|
state: absent
|
|
|
|
# ============================================
|
|
# Remove User and Groups
|
|
# ============================================
|
|
|
|
- name: Remove nextcloud user
|
|
user:
|
|
name: "{{ nextcloud_user }}"
|
|
state: absent
|
|
remove: yes
|
|
force: yes
|
|
|
|
- name: Remove nextcloud group
|
|
group:
|
|
name: "{{ nextcloud_group }}"
|
|
state: absent
|
|
|
|
# ============================================
|
|
# Clean Up Remaining Files
|
|
# ============================================
|
|
|
|
- name: Find nextcloud-related files in /tmp
|
|
find:
|
|
paths: /tmp
|
|
patterns: "nextcloud*,nc_*"
|
|
file_type: any
|
|
register: tmp_files
|
|
|
|
- name: Remove nextcloud temp files
|
|
file:
|
|
path: "{{ item.path }}"
|
|
state: absent
|
|
loop: "{{ tmp_files.files }}"
|
|
when: tmp_files.files | length > 0
|
|
failed_when: false
|
|
|
|
- name: Remove caddy logs for nextcloud
|
|
file:
|
|
path: /var/log/caddy/nextcloud.log
|
|
state: absent
|
|
failed_when: false
|
|
|
|
# ============================================
|
|
# Verification
|
|
# ============================================
|
|
|
|
- name: Verify nextcloud service is removed
|
|
command: systemctl list-units --all nextcloud*
|
|
register: units_check
|
|
changed_when: false
|
|
|
|
- name: Verify nextcloud container is removed
|
|
command: podman ps -a --filter name=nextcloud
|
|
register: container_check
|
|
changed_when: false
|
|
|
|
- name: Display removal status
|
|
debug:
|
|
msg: |
|
|
✅ Nextcloud removal complete!
|
|
|
|
Removed components:
|
|
- ⏹️ Nextcloud service and cron timer
|
|
- 🐳 Container: {{ 'Removed' if container_remove.rc == 0 else 'Not found' }}
|
|
- 🗄️ Database: {{ nextcloud_db_name }}
|
|
- 📁 Data directory: {{ nextcloud_home }}
|
|
- 👤 System user: {{ nextcloud_user }}
|
|
- 🌐 Caddy configuration
|
|
|
|
Remaining services:
|
|
{{ units_check.stdout }}
|
|
|
|
Containers:
|
|
{{ container_check.stdout }}
|
|
|
|
handlers:
|
|
- name: reload caddy
|
|
systemd:
|
|
name: caddy
|
|
state: reloaded
|
|
failed_when: false
|