Skip to content

Instantly share code, notes, and snippets.

@possebon
Created December 19, 2025 17:51
Show Gist options
  • Select an option

  • Save possebon/0e6f0d25851ee6d6b47a7749c9b46d66 to your computer and use it in GitHub Desktop.

Select an option

Save possebon/0e6f0d25851ee6d6b47a7749c9b46d66 to your computer and use it in GitHub Desktop.
Open Source Infrastructure Stack - 16-ansible-credential-resolution

Ansible Credential Resolution Pattern

# Dual-mode: Infisical OR environment variable fallback
postgres_password: >-
  {{
    _infisical_global.POSTGRES_PASSWORD | default(None)
    if infisical_enabled | default(false) | bool and _infisical_global is defined
    else lookup('env', 'POSTGRES_PASSWORD') | default('changeme', true)
  }}

This provides:

  1. Infisical-first: When configured, secrets come from Infisical
  2. Graceful fallback: Environment variables work for local development
  3. Safe defaults: Development never breaks due to missing secrets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment