--- # ============================================================================= # Gitea - Full Cleanup # ============================================================================= # Removes containers and optionally all data # # Usage (containers only): # ansible-playbook -i inventory.yml cleanup-full.yml # # Usage (including data - DESTRUCTIVE): # ansible-playbook -i inventory.yml cleanup-full.yml -e "remove_data=true" # ============================================================================= - name: Gitea - Full Cleanup hosts: gitea_servers become: true vars_files: - group_vars/gitea_servers.yml vars: remove_data: false tasks: - name: Display warning ansible.builtin.debug: msg: | ============================================ WARNING: Full Cleanup ============================================ remove_data: {{ remove_data }} Data directory: {{ gitea_data_dir }} ============================================ - name: Check if docker-compose.yml exists ansible.builtin.stat: path: "{{ gitea_base_dir }}/docker-compose.yml" register: compose_file - name: Stop and remove containers with volumes ansible.builtin.command: cmd: docker compose down -v --remove-orphans chdir: "{{ gitea_base_dir }}" when: compose_file.stat.exists ignore_errors: true changed_when: true - name: Remove OAuth setup script ansible.builtin.file: path: "{{ gitea_base_dir }}/setup-gitea-oauth.sh" state: absent - name: Remove Gitea data directory ansible.builtin.file: path: "{{ gitea_data_dir }}" state: absent when: remove_data | bool - name: Remove base directory ansible.builtin.file: path: "{{ gitea_base_dir }}" state: absent when: remove_data | bool - name: Display cleanup status ansible.builtin.debug: msg: | ============================================ Gitea - Full Cleanup Complete ============================================ Containers: Removed Data: {{ 'REMOVED' if remove_data else 'Preserved at ' + gitea_data_dir }} Note: Authentik OAuth application still exists. To remove, go to Authentik admin panel: https://{{ authentik_domain }}/if/admin/#/core/applications To redeploy: ansible-playbook -i inventory.yml playbook.yml --ask-vault-pass ============================================