Switch to terraform
This commit is contained in:
89
ansible/gitea/migration/cleanup-full.yml
Normal file
89
ansible/gitea/migration/cleanup-full.yml
Normal file
@@ -0,0 +1,89 @@
|
||||
---
|
||||
# =============================================================================
|
||||
# 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"
|
||||
#
|
||||
# Usage (including backups - VERY DESTRUCTIVE):
|
||||
# ansible-playbook -i inventory.yml cleanup-full.yml -e "remove_data=true" -e "remove_backups=true"
|
||||
# =============================================================================
|
||||
|
||||
- name: Gitea - Full Cleanup
|
||||
hosts: gitea_servers
|
||||
become: true
|
||||
vars_files:
|
||||
- group_vars/gitea_servers.yml
|
||||
vars:
|
||||
# Safety flags - must be explicitly enabled
|
||||
remove_data: false
|
||||
remove_backups: false
|
||||
|
||||
tasks:
|
||||
- name: Display warning
|
||||
ansible.builtin.debug:
|
||||
msg: |
|
||||
============================================
|
||||
WARNING: Full Cleanup
|
||||
============================================
|
||||
remove_data: {{ remove_data }}
|
||||
remove_backups: {{ remove_backups }}
|
||||
|
||||
Data directory: {{ gitea_data_dir }}
|
||||
Backup directory: {{ gitea_backup_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 backup directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ gitea_backup_dir }}"
|
||||
state: absent
|
||||
when: remove_backups | 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 }}
|
||||
Backups: {{ 'REMOVED' if remove_backups else 'Preserved at ' + gitea_backup_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
|
||||
|
||||
============================================
|
||||
Reference in New Issue
Block a user