Skip to content

level12/ans-env-loader

Repository files navigation

Ansible Env Vars

Nox pypi

Extracts variables from the local environment and converts them to Ansible variables.

Install and Setup

Install: uv add [--dev] ans-env-loader

Then place an ans-env-vars.yaml and an env-loader.py into your Ansible playbooks root directory as follows:

 ❯ tree
├── ansible.cfg
├── ans-env-vars.yaml
├── hosts.ini
├── playbook.yaml
└── vars_plugins
    ├── env-loader.py


 ❯ cat vars_plugins/env-loader.py
from ans_env_loader import VarsModule as VarsModule


 ❯ cat ans-env-vars.yaml
# Ansible var name is the same as the expected env var
- app_smtp_host
# Map Ansible var name to a different expected env var
- app_flask_secret: FLASK_SECRET

Dev

Copier Template

Project structure and tooling mostly derives from the Coppy, see its documentation for context and additional instructions.

This project can be updated from the upstream repo, see Updating a Project.

Project Setup

From zero to hero (passing tests that is):

  1. Ensure host dependencies are installed

  2. Start docker service dependencies (if applicable):

    docker compose up -d

  3. Sync project virtualenv w/ lock file:

    uv sync

  4. Configure pre-commit:

    pre-commit install

  5. Run tests:

    nox

Versions

Versions are date based. A bump action exists to help manage versions:

  # Show current version
  mise bump --show

  # Bump version based on date, tag, and push:
  mise bump

  # See other options
  mise bump -- --help

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages