node-bootstrap.yaml
Overview
This file defines an Ansible playbook designed to bootstrap a set of block keeper nodes, typically part of a distributed system for managing blockchain or ledger data. It automates the initialization phase to prepare block keeper nodes on targeted hosts for operation.
The playbook is structured to:
Target hosts designated as block keepers (or a custom group defined by the user).
Execute with escalated privileges (
become: yes).Use predefined variables to control actions such as deleting data, starting services, bootstrapping, and updating.
Apply the
block-keeperrole, which contains the detailed tasks and handlers necessary for block keeper bootstrap operations.
Playbook Structure and Components
Play Definition
name:
"Block keeper bootstrap BK set (on running node)"
Describes the purpose of the play, which is to bootstrap block keeper nodes while they are running.hosts:
'{{ target | default("block_keepers") }}'
The play targets hosts specified by thetargetvariable. Iftargetis not provided, it defaults to theblock_keepersgroup. This flexibility allows selective bootstrapping of nodes or groups.gather_facts:
no
Disables fact gathering to speed up execution since this play might not require detailed system facts.become:
yes
Commands are run with escalated privileges (usually root), necessary for system-level operations such as service management or file system changes.
Variables
Several variables control the behavior of the bootstrap process:
Variable | Type | Default | Description |
|---|---|---|---|
DELETE_DATA | boolean |
| Indicates whether existing block keeper data should be deleted before bootstrapping. |
DO_START | boolean |
| Controls whether the block keeper service should be started after bootstrapping. |
DO_BOOTSTRAP | boolean |
| Enables the bootstrap process itself. |
FAST_UPDATE | boolean |
| Specifies if the bootstrap should perform a fast update, potentially skipping some verification steps. |
Roles
block-keeper
This role encapsulates the tasks, handlers, and templates required to bootstrap the block keeper nodes. It likely includes:Preparing directories and configurations.
Managing service state (stop/start).
Performing data initialization based on the variables above.
Applying updates or patches.
The exact role implementation is external to this file but is integral to the bootstrap workflow.
Usage Example
To bootstrap the default block keeper group with the settings defined:
ansible-playbook node-bootstrap.yaml
To target a specific group or host, override the target variable:
ansible-playbook node-bootstrap.yaml -e "target=custom_block_keeper_group"
To delete existing data and start the service after bootstrapping:
ansible-playbook node-bootstrap.yaml -e "DELETE_DATA=yes DO_START=yes"
Implementation Details
The playbook avoids gathering facts to minimize execution time.
Privilege escalation ensures necessary access to system resources.
Variables provide flexibility in controlling the bootstrap process without modifying the playbook itself.
The use of roles promotes modularity and separation of concerns, delegating detailed bootstrap operations to the
block-keeperrole.The default settings imply a non-destructive bootstrap process that does not start services automatically but performs bootstrap and fast update operations.
Interaction with Other System Components
block-keeper role: This playbook is a driver that delegates the actual bootstrap tasks to the
block-keeperrole. This role manages all the detailed operations such as data setup, service control, and configuration.Inventory groups: The playbook interacts with Ansible inventory to identify which hosts constitute the
block_keepersor any alternative group passed viatarget.Block keeper nodes: It runs on the nodes themselves, preparing them to operate in the larger distributed system, possibly interacting with blockchain networks or ledger data stores.
Service management: Through role tasks, system services related to block keepers are managed according to flags set in the playbook variables.
Visual Diagram
flowchart TD
A[Start Play] --> B{Hosts}
B -->|target variable| C[Target hosts]
B -->|default| D[block_keepers group]
C --> E[Set Variables]
D --> E
E --> F[Apply block-keeper Role]
F --> G{Role Tasks}
G --> H[Delete Data?]
G --> I[Bootstrap if DO_BOOTSTRAP=yes]
G --> J[Perform Fast Update if FAST_UPDATE=yes]
G --> K[Start Service if DO_START=yes]
K --> L[End Play]
H --> I
I --> J
J --> K
The diagram reflects the flow from play start, host selection based on the target variable or default group, through variable setup, application of the role, conditional steps based on variables, and play completion.