stop-delete-data.yaml

Overview

This YAML file defines a sequence of Ansible tasks aimed at performing a controlled shutdown of a service environment, followed by the cleanup of related Docker containers and removal of persistent data directories and configuration files. It is primarily used to stop running components gracefully and ensure that no residual data or configuration artifacts remain on the host system.

The tasks are executed in order to:

  1. Trigger a graceful shutdown of nodes to speed up the process.

  2. Stop and remove Docker containers and orphaned services related to the application.

  3. Remove the persistent data directory to clear stored data.

  4. Delete a specific configuration file (bk_set.json) associated with the backup set.

Detailed Description of Tasks

1. Node graceful shutdown for speedup

- name: Node graceful shutdown for speedup
  include_tasks: graceful-shutdown.yaml
  vars:
    GS_WAIT: no

2. Compose down

- name: Compose down
  ansible.builtin.shell:
    chdir: "{{ BK_DIR }}"
    cmd: docker compose down --remove-orphans
  ignore_errors: true

3. Remove data folder

- name: Remove data folder
  ansible.builtin.file:
    path: "{{ BK_DATA_DIR }}"
    state: absent

4. Remove stored BK set

- name: Remove stored BK set
  ansible.builtin.file:
    path: "{{ BK_DIR }}/bk-configs/bk_set.json"
    state: absent

Implementation Details and Algorithms

Interaction with Other Components

Visual Diagram

flowchart TD
A[Start] --> B[Node graceful shutdown]
B --> C[Docker Compose down]
C --> D[Remove data folder]
D --> E[Remove bk_set.json]
E --> F[End]
subgraph GracefulShutdown
B
end
subgraph DockerCleanup
C
end
subgraph CleanupData
D --> E
end

For further details on Ansible task structures and modules used, reference Ansible Tasks and Modules. For information about Docker Compose command usage and options, see Docker Compose. For node shutdown procedures, refer to Node Management.