Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

Implements the foundational infrastructure for consolidating Ansible playbook variables into a centralized variables.yml file, following the same pattern as OpenTofu's variables.tfvars.tera.

Implementation

Template & Context

  • Template: templates/ansible/variables.yml.tera - Centralized variable definitions with SSH port
  • Context: AnsibleVariablesContext - Validates SSH port using existing AnsiblePort validation

Wrapper & Renderer

  • Wrapper: AnsibleVariablesTemplate - Renders template with domain TemplateEngine
  • Renderer: VariablesTemplateRenderer - Orchestrates template loading, context processing, and file output
  • Integration: Hooked into AnsibleTemplateRenderer::render() workflow after firewall playbook rendering

Error Handling

  • Added ContextCreationFailed error variant for SSH port validation failures
  • Updated both create_firewall_context() and create_variables_context() to use semantically correct error types

Output

Generated variables.yml contains runtime SSH port configuration:

---
# Centralized Ansible Variables
ssh_port: 22
# Future service variables can be added here when needed

Architecture

Follows existing three-layer template pattern:

  1. Context Layer - Validates input data (SSH port)
  2. Wrapper Layer - Renders Tera template with validated context
  3. Renderer Layer - Orchestrates file I/O and template management

Future service variables (MySQL, Tracker, Prometheus, Grafana) can be added to the template without additional Rust infrastructure per service.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create Variables Template Infrastructure</issue_title>
<issue_description>Parent Epic: #19 - Refactor Ansible Templates to Variables Pattern

Overview

Create the centralized variables.yml.tera template and supporting Rust infrastructure (context, wrapper, renderer) to consolidate Ansible playbook variables into a single file. This establishes the foundation for the variables pattern that will simplify future playbook additions.

Goals

  • Variables Template: Create templates/ansible/variables.yml.tera with system configuration variables
  • Context Layer: Implement AnsibleVariablesContext with validation
  • Wrapper Layer: Implement AnsibleVariablesTemplate for rendering
  • Renderer Layer: Implement VariablesTemplateRenderer for orchestration
  • Integration: Hook into AnsibleTemplateRenderer::render() workflow
  • Test Coverage: Comprehensive unit tests for all components

🏗️ Architecture Requirements

DDD Layer: Infrastructure
Module Path: src/infrastructure/external_tools/ansible/template/
Pattern: Template Wrapper + Context + Renderer (existing pattern)

Time Estimate

2.5 days - Complete vertical slice including implementation, testing, and documentation

Documentation

Full implementation details: docs/issues/19.1-create-variables-template.md

Acceptance Criteria

Template File

  • templates/ansible/variables.yml.tera exists with SSH port variable
  • Template has correct Tera syntax: {{ ssh_port }}
  • YAML linting passes

Implementation

  • AnsibleVariablesContext with SSH port validation
  • AnsibleVariablesTemplate wrapper implementation
  • VariablesTemplateRenderer orchestrator
  • Integration into AnsibleTemplateRenderer

Testing

  • Unit tests pass: cargo test
  • Config tests pass: cargo run --bin e2e-config-tests
  • Linters pass: cargo run --bin linter all
  • variables.yml generated in build directory

Documentation

  • Rustdoc comments for all public types
  • Template file includes descriptive comments
  • Error types have clear descriptions

Related

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Create Variables Template Infrastructure feat: Add centralized variables template infrastructure for Ansible playbooks (#105) Nov 3, 2025
Copilot AI requested a review from josecelano November 3, 2025 08:57
@josecelano josecelano marked this pull request as ready for review November 3, 2025 10:03
Copy link
Member

@josecelano josecelano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK e162cf1

@josecelano josecelano merged commit 6cd06ce into main Nov 3, 2025
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Variables Template Infrastructure

2 participants