copy-static-configs.yaml
Overview
This YAML file is an Ansible playbook designed to automate the copying of specific static files into a Block Keeper (BK) directory structure. It primarily handles the transfer of WebAssembly (WASM) binary files, configuration files, key files, and an environment configuration file (.env) for container orchestration. This setup is essential for preparing the runtime environment of Block Keeper by ensuring all necessary binaries and configuration files are correctly placed before service startup.
Tasks and Their Functionality
The playbook consists of three main tasks executed sequentially:
1. Copy WASM binaries to Block Keeper
Purpose: Copies a predefined set of WASM binary files from a local wasm/ directory to the bk-binaries/wasm folder inside the Block Keeper directory.
Implementation Details:
Uses the Ansible copy module.
The destination path is constructed using the variable
BK_DIR, which represents the root directory for Block Keeper.The task loops over a hardcoded list of WASM binary filenames represented by their hash-like strings.
Parameters:
Usage Example:
When executed, this task copies each listed WASM binary file from the wasm/ directory on the local machine to the corresponding directory in Block Keeper, preserving the filename.
2. Copy configuration files
Purpose: Copies node configuration files, node owner keys, and other related keys into the Block Keeper configs directory.
Implementation Details:
Uses the Ansible copy module.
The destination directory is
{{ BK_DIR }}/bk-configs/.The source files are specified via three variables: NODE_CONFIGS, NODE_OWNER_KEY, and
OTHER_KEYS.The task uses the
with_itemsloop to iterate over these variables.
Parameters:
Usage Example:
Copies all node-related configuration and key files into the Block Keeper configs directory to ensure proper identity and operational parameters are available.
3. Copy .env file for container orchestration (compose)
Purpose: Conditionally copies a
.envfile into the Block Keeper root directory, which is typically used by Docker Compose or similar container orchestration tools.Implementation Details:
Uses the Ansible copy module.
The task is executed only if the variable
COPY_ENVis defined and evaluates to true.
Parameters:
Usage Example:
Allows dynamic control over whether environment variables for container orchestration should be copied, providing flexibility in deployment scenarios.
Important Implementation Details
Variables:
BK_DIR: The base directory path for Block Keeper; expected to be defined in the environment or in higher-level playbooks.NODE_CONFIGS, NODE_OWNER_KEY,
OTHER_KEYS: Variables representing lists or single files of configurations and keys, expected to be defined elsewhere.COPY_ENV: A boolean flag controlling the conditional copying of the.envfile.
Loop Constructs:
The WASM binaries are iterated using loop, a standard Ansible construct for repetitive tasks.
The configuration files are iterated using
with_items, another Ansible loop mechanism.
Conditional Execution:
The
.envfile copy uses awhenclause to allow optional execution depending on deployment requirements.
File Structure and Naming:
WASM binaries are named by their cryptographic hash strings to ensure integrity and uniqueness.
Configuration and key files are dynamically specified, enabling flexible deployment configurations.
Interaction with Other System Components
This playbook is typically invoked as part of a larger deployment or setup process for Block Keeper.
The files copied here are prerequisites for Block Keeper's operation:
WASM binaries are required for executing smart contracts or other WebAssembly-based logic.
Configuration files and keys define node behavior and security credentials.
The
.envfile configures environment variables for containerized services.
The variables (
BK_DIR, NODE_CONFIGS, etc.) are expected to be defined or passed in from other parts of the system deployment automation.The playbook’s output prepares the filesystem so that subsequent steps (e.g., starting services, running containers) can operate with all necessary static resources.
Workflow Diagram
flowchart TD
A[Start Playbook] --> B[Copy WASM binaries]
B --> C[Copy Config Files & Keys]
C --> D{COPY_ENV defined and true?}
D -- Yes --> E[Copy .env File]
D -- No --> F[Skip .env Copy]
E & F --> G[End Playbook]
Explanation:
The playbook starts by copying WASM binaries.
Then, it copies configuration and key files.
Finally, it conditionally copies the
.envfile based on theCOPY_ENVvariable.The process ends after these steps complete.
This file's role is foundational in setting up the runtime environment for Block Keeper by ensuring all necessary static files are present in designated directories before runtime. It is a critical step in deployment automation workflows.