proxy-deployment.yaml

Overview

This file is an Ansible playbook designed to automate the deployment and management of a proxy service environment. It primarily focuses on preparing necessary directories, managing proxy certificates and keys, configuring the proxy service with Docker Compose, and handling log rotation. The playbook supports both scenarios where proxy certificates are generated as part of the deployment and where pre-existing certificates are used.

Key features include:

This playbook is intended to be run in an environment where variables such as PROXY_DIR, PROXY_CERTS_DIR, PROXY_SIGNING_KEYS, GENERATE_CERT, and CLEANUP_BK_KEYS are defined externally.


Tasks and Their Functional Details

1. Ensure Proxy Directories Exist

2. Gather Network Interface Facts

3. Copy Block Keeper Keys to Proxy

4. Check That Proxy Certificate and Key Exist

5. Generate Configuration Files Using Templates

6. Manage Docker Compose Lifecycle

7. Backup Existing Proxy Certificates and Keys

8. Wait for Proxy Certificate and Key Availability

9. Remove Old Backup Certificates and Keys

10. Securely Shred and Remove Block Keeper Keys After Deployment


Variables Used

Variable Name

Purpose

Expected Type

PROXY_DIR

Directory path where proxy files and configs are stored

String (path)

PROXY_CERTS_DIR

Directory path for proxy certificates and keys

String (path)

PROXY_SIGNING_KEYS

List of signing key file paths for Block Keeper

List of strings (paths)

GENERATE_CERT

Flag indicating whether to generate new certificates

Boolean

CLEANUP_BK_KEYS

Flag indicating whether to shred and remove signing keys after deployment

Boolean


Interaction with Other Parts of the System

These interactions ensure that the proxy deployment is fully automated, consistent, and secure within the broader infrastructure management workflow.


Implementation Details and Algorithms


Visual Diagram: Workflow of proxy-deployment.yaml

flowchart TD
A[Start Deployment] --> B[Ensure Proxy Dirs Exist]
B --> C[Gather Network Facts]
C --> D{GENERATE_CERT?}
D -- Yes --> E[Copy Block Keeper Keys]
D -- No --> F[Check Proxy Cert & Key]
E --> G[Backup Existing Certs & Keys]
G --> H[Generate Configs from Templates]
F --> H
H --> I[Docker Compose Pull]
I --> J{GENERATE_CERT?}
J -- Yes --> K[Docker Compose Down]
J -- No --> L[Skip Down]
K --> M[Docker Compose Up]
L --> M
M --> N[Restart Logrotate if Changed]
N --> O{GENERATE_CERT?}
O -- Yes --> P[Wait for Cert & Key Availability]
P --> Q[Remove Backup Certs & Keys]
Q --> R{CLEANUP_BK_KEYS?}
O -- No --> R
R -- Yes --> S[Securely Shred Block Keeper Keys]
R -- No --> T[Skip Key Cleanup]
S --> U[Remove Block Keeper Keys]
T --> U
U --> V[End Deployment]

This flowchart represents the conditional logic and sequential flow of tasks in the playbook, highlighting key decision points related to certificate generation and cleanup operations.