https://github.com/level12/ans-env-loader
https://github.com/level12/ans-env-loader
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/level12/ans-env-loader
- Owner: level12
- Created: 2025-06-23T03:29:41.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-23T04:25:31.000Z (12 months ago)
- Last Synced: 2025-06-23T04:31:16.590Z (12 months ago)
- Language: Python
- Size: 136 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Ansible Env Vars
[](https://github.com/level12/ans-env-loader/actions/workflows/nox.yaml)
[](https://pypi.org/project/ans-env-loader/)
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:
```sh
❯ 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](https://github.com/level12/coppy),
see its documentation for context and additional instructions.
This project can be updated from the upstream repo, see
[Updating a Project](https://github.com/level12/coppy?tab=readme-ov-file#updating-a-project).
### Project Setup
From zero to hero (passing tests that is):
1. Ensure [host dependencies](https://github.com/level12/coppy/wiki/Mise) are installed
2. Start docker service dependencies (if applicable):
`docker compose up -d`
3. Sync [project](https://docs.astral.sh/uv/concepts/projects/) 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:
```shell
# Show current version
mise bump --show
# Bump version based on date, tag, and push:
mise bump
# See other options
mise bump -- --help
```