start-bm.yaml

Overview

This Ansible playbook automates the setup and management of a block manager (BM) environment. It primarily handles the creation of necessary directories, copying and registering key files, preparing Docker Compose configurations, setting up scheduled tasks for database rotation, managing Docker networks, and controlling the lifecycle of Docker containers related to the block manager. The playbook ensures that the BM environment is correctly initialized and maintained with appropriate file permissions, scheduled maintenance, and container orchestration.

Detailed Breakdown of Tasks

Directory and File Management

Key Extraction and Fact Registration

Docker Compose and Container Management

Scheduled Tasks and Maintenance

Important Implementation Details

Interaction with Other System Components

Visual Diagram

flowchart TD
A[Start: Ensure Directories] --> B[Create BM and Logs directories]
B --> C[Create bm-configs directory]
C --> D[Copy Wallet & Signer Keys]
D --> E[Extract Public Key using jq]
E --> F[Set Public Key Fact]
F --> G[Render Docker Compose Template]
G --> H[Copy bm-rotate.sh Script]
H --> I[Create Cron Job for DB Rotation]
I --> J[Render Logrotate Template]
J --> K[Pull Docker Images]
K --> L{CREATE_NET?}
L -- Yes --> M[Create Docker Network]
L -- No --> N[Skip Network Creation]
M & N --> O[Start Docker Compose Services]
O --> P{Logrotate Changed?}
P -- Yes --> Q[Restart logrotate Container]
P -- No --> R[End]

This flowchart illustrates the sequential steps and conditional logic within the playbook, highlighting directory setup, key management, Docker orchestration, and scheduled maintenance tasks.