Core Concepts
Variables

Variables in Ctrlplane

Variables in Ctrlplane are key-value pairs that enable dynamic configuration and parameterization of deployment workflows. They're essential for injecting environment-specific settings, secrets, and runtime values into your pipelines.

Variable Scopes

Ctrlplane offers three variable scopes:

  1. System Level: Global variables applicable to all targets across all deployments within a system.
  2. Deployment Level (Wildcard Selector): Variables applicable to all targets within a specific deployment.
  3. Deployment Level (Custom Selector): Variables applicable to a subset of targets within a deployment, based on defined selectors (e.g., labels, environment, type).

Precedence and Conflict Resolution

When variable keys are defined at multiple levels, Ctrlplane resolves conflicts in this order:

  1. Per-Target Variables (highest priority)
  2. Deployment Level Variables
  3. System Level Variables (lowest priority)

Variable Types

Ctrlplane supports:

  • String: Plain text (e.g., API_KEY)
  • Number: Numeric values (e.g., PORT)
  • Boolean: True/False values (e.g., ENABLE_DEBUG)
  • Array: List of values (e.g., ALLOWED_IPS)
  • Object: Structured data (e.g., DATABASE_CONFIG)
  • Secret: Encrypted sensitive values (e.g., passwords)

Usage

Variables can be used in:

  • Workflow definitions: {{ vars.api_key }}
  • Job agent configurations
  • Target configurations

Best Practices

  1. Organize variables logically at the appropriate level
  2. Use descriptive names
  3. Store sensitive values as secrets

Implementation Tips

  • Use system-level variables for shared configurations (e.g., global API endpoints, common timeouts)
  • Leverage deployment-level variables for environment-specific settings (e.g., staging vs. production configs)
  • Utilize custom selectors for fine-grained control over specific target groups
  • Regularly audit and rotate sensitive variables, especially secrets

By mastering Ctrlplane's variable system, DevOps engineers can create flexible, secure, and easily maintainable deployment workflows across diverse environments.

Ctrlplane
© 2024 Ctrlplane. All rights reserved.