Replaces the minimal project description with a comprehensive README including a component overview table, quick start instructions, common Ansible operations, and links to detailed documentation. Aligns with Red Panda Approval™ standards.
76 lines
2.4 KiB
YAML
76 lines
2.4 KiB
YAML
---
|
|
# -----------------------------------------------------------------------------
|
|
# Casdoor Removal Playbook
|
|
# -----------------------------------------------------------------------------
|
|
# Removes Casdoor SSO including:
|
|
# - Docker containers and volumes
|
|
# - Configuration files
|
|
# - PostgreSQL data directory
|
|
# - Service user and group
|
|
#
|
|
# WARNING: This will permanently delete all Casdoor data including the database!
|
|
# -----------------------------------------------------------------------------
|
|
|
|
- name: Remove Casdoor
|
|
hosts: ubuntu
|
|
tasks:
|
|
- name: Check if host has casdoor service
|
|
ansible.builtin.set_fact:
|
|
has_casdoor_service: "{{ 'casdoor' in services | default([]) }}"
|
|
|
|
- name: Skip hosts without casdoor service
|
|
ansible.builtin.meta: end_host
|
|
when: not has_casdoor_service
|
|
|
|
# -------------------------------------------------------------------------
|
|
# Stop and Remove Docker Services
|
|
# -------------------------------------------------------------------------
|
|
|
|
- name: Check if docker-compose.yml exists
|
|
become: true
|
|
ansible.builtin.stat:
|
|
path: "{{ casdoor_directory }}/docker-compose.yml"
|
|
register: compose_file
|
|
|
|
- name: Stop and remove Casdoor containers
|
|
become: true
|
|
community.docker.docker_compose_v2:
|
|
project_src: "{{ casdoor_directory }}"
|
|
state: absent
|
|
remove_volumes: true
|
|
when: compose_file.stat.exists
|
|
|
|
# -------------------------------------------------------------------------
|
|
# Remove Data Directory
|
|
# -------------------------------------------------------------------------
|
|
|
|
- name: Remove casdoor directory and all data
|
|
become: true
|
|
ansible.builtin.file:
|
|
path: "{{ casdoor_directory }}"
|
|
state: absent
|
|
|
|
# -------------------------------------------------------------------------
|
|
# Remove User and Group
|
|
# -------------------------------------------------------------------------
|
|
|
|
- name: Remove ponos from casdoor group
|
|
become: true
|
|
ansible.builtin.command:
|
|
cmd: gpasswd -d ponos {{ casdoor_group }}
|
|
register: gpasswd_result
|
|
changed_when: gpasswd_result.rc == 0
|
|
failed_when: false
|
|
|
|
- name: Remove casdoor user
|
|
become: true
|
|
ansible.builtin.user:
|
|
name: "{{ casdoor_user }}"
|
|
state: absent
|
|
|
|
- name: Remove casdoor group
|
|
become: true
|
|
ansible.builtin.group:
|
|
name: "{{ casdoor_group }}"
|
|
state: absent
|