node-clean-data.yml

Overview

The node-clean-data.yml file is an automation playbook designed to manage and reset data on block keeper nodes within a distributed system. It primarily focuses on restarting block keeper services with options to delete existing data, control service startup, and enable fast update modes. This playbook is intended to be executed on a defined group of hosts, allowing systematic and consistent data cleanup operations across the targeted nodes.

Purpose and Functionality

Playbook Structure and Parameters

Key

Description

name

Describes the playbook task: "reset block keeper services data".

gather_facts

Disabled (no) to speed up playbook execution when system facts are not required.

hosts

Target hosts for the playbook. Defaults to block_keepers group if target variable is unset.

become

Enables privilege escalation to run tasks as a superuser (yes).

any_errors_fatal

Ensures that any error during execution halts the entire playbook run (true).

vars

Defines variables controlling data deletion, service startup, and update mode.

roles

Specifies the block-keeper role to execute the relevant service management tasks.

Variables

Hosts Specification

The playbook targets the hosts in the block_keepers group by default. However, this can be overridden by providing a target variable during execution, allowing flexibility to run on different or specific nodes.

Role Interaction: block-keeper

This playbook delegates the execution of detailed tasks to the block-keeper role. This role is responsible for:

This separation of concerns allows the playbook to serve as a high-level orchestrator, while the role encapsulates the implementation specifics.

Usage Example

To run this playbook on the default group (block_keepers), with data deletion enabled but without starting the services:

ansible-playbook node-clean-data.yml

To override the target hosts and enable service startup:

ansible-playbook node-clean-data.yml -e "target=custom_block_keepers DO_START=yes"

Implementation Details

Interaction with Other Components


Mermaid Diagram

flowchart TD
A[Start Playbook] --> B{Gather Facts?}
B -- No --> C[Set Variables DELETE_DATA, DO_START, FAST_UPDATE]
C --> D["Select Hosts (target or block_keepers)"]
D --> E[Execute block-keeper Role]
E --> F{DELETE_DATA == yes?}
F -- Yes --> G[Delete Block Keeper Data]
F -- No --> H[Skip Data Deletion]
G --> I{DO_START == yes?}
H --> I
I -- Yes --> J[Start Block Keeper Services]
I -- No --> K[Keep Services Stopped]
J --> L{FAST_UPDATE == yes?}
K --> L
L -- Yes --> M[Perform Fast Update Workflow]
L -- No --> N[Perform Standard Update Workflow]
M --> O[End Playbook]
N --> O

The above flowchart outlines the primary workflow of the playbook, illustrating decision points based on variable settings and the delegation to the block-keeper role for task execution.