node-stopping.yml
Overview
The node-stopping.yml file is an automation playbook designed to manage the stopping process of "block keeper" nodes within a distributed system. It focuses on safely halting these nodes while optionally configuring behavior parameters such as whether to delete data or perform a fast update. The playbook is executed on a specified group of hosts, with default targeting set to the block_keepers inventory group.
This playbook is part of the orchestration system that controls lifecycle management of block keeper nodes, ensuring coordinated stopping actions, which may be critical for maintenance, upgrades, or controlled shutdowns.
Structure and Components
Play Definition
Name:
Block keeper stopping
Provides a descriptive label for the play, indicating its purpose to stop block keeper nodes.Hosts:
Targets hosts based on the variabletarget. Iftargetis undefined, defaults toblock_keepers. This allows flexibility to specify different target groups dynamically.Privilege Escalation:
Usesbecome: yesto execute tasks with elevated privileges, which is typically necessary for service management and system-level changes.Error Handling:
any_errors_fatal: trueensures that if any task fails on any host, the playbook aborts immediately to prevent partial or inconsistent states across the cluster.
Variables
The playbook defines several variables to control its behavior:
DELETE_DATA: no
Controls whether data associated with the block keeper nodes should be deleted during the stopping process.DO_START: no
Indicates that starting nodes is not part of this playbook's operation.DO_STOP: yes
Specifies that the stopping action should be performed.FAST_UPDATE: yes
Suggests that the stopping process should use a fast update mechanism, likely minimizing downtime or accelerating state transition.
Roles
block-keeper
The playbook includes a role namedblock-keeper, which encapsulates the tasks, handlers, and templates necessary to manage block keeper nodes. This role is responsible for interpreting the control variables and executing the appropriate steps to stop the nodes accordingly.
Important Implementation Details
The playbook does not gather facts (
gather_facts: no), which optimizes execution time by skipping system information collection. This implies that the stopping procedure does not depend on dynamic system facts.The use of variables like
DO_STOPandDO_STARTsuggests that the underlying role (block-keeper) can handle multiple lifecycle operations, and variables toggle the specific action to execute.The
DELETE_DATAvariable allows the playbook to optionally remove data, indicating that this stopping process can be either a soft stop (preserving data) or a hard stop (cleaning up data).The
FAST_UPDATEflag potentially influences how the role handles state transitions, possibly affecting service restart policies or cluster state synchronization.
Interaction with Other System Components
Roles:
Theblock-keeperrole is a critical dependency of this playbook. It contains the operational logic for stopping block keeper nodes and likely interacts with system services, configuration files, and cluster state management components.Inventory and Targeting:
The playbook interacts with the inventory system through thehostsdirective, targeting either a default group or a user-specified subset of nodes. This enables flexible deployment and management strategies.Control Hosts:
The comment about adding a target variable due to control hosts suggests that this playbook is designed to be run either directly on hosts or via a control node, adapting its target accordingly.
Usage Example
To run this playbook and stop the default group of block keeper nodes without deleting data:
ansible-playbook node-stopping.yml
To target a specific subset of block keeper nodes, e.g., block_keepers_1:
ansible-playbook node-stopping.yml -e "target=block_keepers_1"
To stop nodes and delete their data:
ansible-playbook node-stopping.yml -e "DELETE_DATA=yes"
Visual Diagram
flowchart TD
A[Start node-stopping.yml playbook]
B{Determine target hosts}
C[Set variables: DELETE_DATA, DO_STOP, DO_START, FAST_UPDATE]
D[Invoke block-keeper role]
E{Role reads variables}
F[Stop block keeper nodes]
G{If DELETE_DATA = yes}
H[Delete block keeper data]
I[Complete stopping process]
A --> B --> C --> D --> E
E --> F
F --> G
G -->|yes| H --> I
G -->|no| I
This flowchart illustrates the main workflow of the playbook: selecting target hosts, setting control variables, invoking the role, performing the stop operation, optionally deleting data, and completing the process.