Name | env-alias JSON |
Version |
0.5.3
JSON |
| download |
home_page | None |
Summary | Powerful helper utility to create shell alias commands to easily set collections of environment variables often with secret values from a variety of data-sources and data-formats. |
upload_time | 2024-09-28 07:38:04 |
maintainer | None |
docs_url | None |
author | Nicholas de Jong |
requires_python | <4.0,>=3.8 |
license | BSD-2-Clause |
keywords |
env-alias
shell
env
alias
bash
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Env Alias
[![PyPi](https://img.shields.io/pypi/v/env-alias.svg)](https://pypi.python.org/pypi/env-alias/)
[![Python Versions](https://img.shields.io/pypi/pyversions/env-alias.svg)](https://github.com/ndejong/env-alias/)
[![Build Status](https://github.com/ndejong/env-alias/actions/workflows/build-tests.yml/badge.svg)](https://github.com/ndejong/env-alias/actions/workflows/build-tests.yml)
[![Read the Docs](https://img.shields.io/readthedocs/env-alias)](https://env-alias.readthedocs.io)
![License](https://img.shields.io/github/license/ndejong/env-alias.svg)
Env Alias is an environment variable swiss-army-knife that enables loading complex collections
of environment variables from a variety of sources only when you require them, thus reducing risks
in working with sensitive environment values.
A variety of data-formats are supported including **JSON**, **YAML**, **Keepass**, **Ansible Vault**,
**Plaintext** and **Ini**-config where these formats can be sourced from the local-filesystem,
http-remote or generated through shell-command exec output.
For example setting an Ansible-vault password file and loading AWS access credentials from values stored
in a git project based Keepass file:
```yaml
env-alias:
MYPROJECT_KEEPASS_FILE:
name: null # prevents this value being assigned into env
exec: 'echo "$(git rev-parse --show-toplevel)/secrets/myproject-keepass.kdbx"'
MYPROJECT_KEEPASS_PASSPHRASE:
source: "<getpass>" # obtain value from user-input using getpass method
override: false # if this env-value exists then skip setting again
MYPROJECT_ANSIBLE_VAULT_PASSWORD:
name: null # prevents this value being assigned into env
source: "env:MYPROJECT_KEEPASS_FILE"
selector: "myproject-name/ansible-vault-entry-name:Password" # select an item from Keepass file
keepass_password: "env:MYPROJECT_KEEPASS_PASSPHRASE"
ANSIBLE_VAULT_PASSWORD_FILE:
ansible_vault_password: "env:MYPROJECT_ANSIBLE_VAULT_PASSWORD" # NB: see docs how this gets managed
ansible_vault_password_file: true # invoke special helper that renders an Ansible Vault password file
AWS_SECRET_ACCESS_KEY:
source: "env:MYPROJECT_KEEPASS_FILE"
selector: "myproject-name/aws-entry-name:Password"
keepass_password: "env:MYPROJECT_KEEPASS_PASSPHRASE"
AWS_ACCESS_KEY_ID:
source: "env:MYPROJECT_KEEPASS_FILE"
selector: "myproject-name/aws-entry-name:Username"
keepass_password: "env:MYPROJECT_KEEPASS_PASSPHRASE"
```
The above example sets the environment variable `MYPROJECT_KEEPASS_PASSPHRASE` with user input using
the `getpass` Python module only if not already set (`override=false`). This environment value is then
used as the `keepass` passphrase to open a Keepass file where values are then selected and exported
into the shell environment.
Substantially more complex env-alias definitions can be created.
By naming your env-aliases with an easy to remember prefix such as `env-` it is also possible to
leverage shell **tab-completion** thus making it easier to find the env-alias definitions created
for your project or other use-case situation.
## Features
Env Alias is enormously useful in working with large sets of environment variables from remote, encrypted
or otherwise secured data-sources.
* Data sources: **local-files**, **http-remote** and stdout from an **exec** command-line.
* Source formats supported: **JSON**, **YAML**, **Keepass**, **Ansible Vault**, **Plaintext** and **Ini**-config.
* Select values using **jq** style selectors, **xpath** style selectors or **line-numbers**.
* 💥 Additional special handling for **Ansible Vault Password Files** that makes credential handling for **Ansible Vault** files substantially easier with reduced exposure risks. 💥
* Self reference environment values in the definition file or from the existing system environment.
* Define variables with a `null` name to prevent them being exported into the system environment while still being available for self-reference within the env-alias definition; this is helpful when working with sensitive values that should not be available through the system environment.
* Ability to use `exec` commands to setup other project prerequisites or other project start conditions.
* Debug mode output to STDERR.
* Easy installation from PyPI.
* Plenty of documentation and examples - [https://env-alias.readthedocs.io](https://env-alias.readthedocs.io)
## Installation
Pip or pipx should be fine, we prefer pipx these days.
```shell
pipx install env-alias
```
## Usage
This tool is typically invoked using an entry in `.bash_aliases` with an entry of the form:-
```shell
source <(env-alias ~/projects/awesome/env-awesome-vars.yml)
```
This simple `.bash_aliases` one-line entry creates the alias `env-awesome-project` by inferring the
alias-name from the filename, where this alias then invokes env-alias to set environment values
defined in `env-awesome-project.yml`
Alternatively, you might want to create the alias `awesome-envvars` which you could do as per -
```shell
source <(env-alias awesome-envvars ~/projects/awesome/env-awesome-vars.yml)
```
## Project
* Github - [github.com/ndejong/env-alias](https://github.com/ndejong/env-alias)
* PyPI - [pypi.python.org/pypi/env-alias](https://pypi.python.org/pypi/env-alias/)
* ReadTheDocs - [env-alias.readthedocs.io](https://env-alias.readthedocs.io)
---
Copyright © (2020-2024) Nicholas de Jong
Raw data
{
"_id": null,
"home_page": null,
"name": "env-alias",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "env-alias, shell, env, alias, bash",
"author": "Nicholas de Jong",
"author_email": "contact@nicholasdejong.com",
"download_url": "https://files.pythonhosted.org/packages/d5/0c/d1e1f3cc70441ea50d401fc8a7da01feafc91fed7ee0883d6d10d87e6037/env_alias-0.5.3.tar.gz",
"platform": null,
"description": "# Env Alias\n\n[![PyPi](https://img.shields.io/pypi/v/env-alias.svg)](https://pypi.python.org/pypi/env-alias/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/env-alias.svg)](https://github.com/ndejong/env-alias/)\n[![Build Status](https://github.com/ndejong/env-alias/actions/workflows/build-tests.yml/badge.svg)](https://github.com/ndejong/env-alias/actions/workflows/build-tests.yml)\n[![Read the Docs](https://img.shields.io/readthedocs/env-alias)](https://env-alias.readthedocs.io)\n![License](https://img.shields.io/github/license/ndejong/env-alias.svg)\n\nEnv Alias is an environment variable swiss-army-knife that enables loading complex collections \nof environment variables from a variety of sources only when you require them, thus reducing risks \nin working with sensitive environment values.\n\nA variety of data-formats are supported including **JSON**, **YAML**, **Keepass**, **Ansible Vault**, \n**Plaintext** and **Ini**-config where these formats can be sourced from the local-filesystem, \nhttp-remote or generated through shell-command exec output.\n\nFor example setting an Ansible-vault password file and loading AWS access credentials from values stored \nin a git project based Keepass file: \n```yaml\nenv-alias:\n\n MYPROJECT_KEEPASS_FILE:\n name: null # prevents this value being assigned into env\n exec: 'echo \"$(git rev-parse --show-toplevel)/secrets/myproject-keepass.kdbx\"'\n \n MYPROJECT_KEEPASS_PASSPHRASE:\n source: \"<getpass>\" # obtain value from user-input using getpass method\n override: false # if this env-value exists then skip setting again\n \n MYPROJECT_ANSIBLE_VAULT_PASSWORD:\n name: null # prevents this value being assigned into env\n source: \"env:MYPROJECT_KEEPASS_FILE\"\n selector: \"myproject-name/ansible-vault-entry-name:Password\" # select an item from Keepass file\n keepass_password: \"env:MYPROJECT_KEEPASS_PASSPHRASE\"\n\n ANSIBLE_VAULT_PASSWORD_FILE:\n ansible_vault_password: \"env:MYPROJECT_ANSIBLE_VAULT_PASSWORD\" # NB: see docs how this gets managed\n ansible_vault_password_file: true # invoke special helper that renders an Ansible Vault password file\n\n AWS_SECRET_ACCESS_KEY:\n source: \"env:MYPROJECT_KEEPASS_FILE\"\n selector: \"myproject-name/aws-entry-name:Password\"\n keepass_password: \"env:MYPROJECT_KEEPASS_PASSPHRASE\"\n \n AWS_ACCESS_KEY_ID:\n source: \"env:MYPROJECT_KEEPASS_FILE\"\n selector: \"myproject-name/aws-entry-name:Username\"\n keepass_password: \"env:MYPROJECT_KEEPASS_PASSPHRASE\"\n\n```\n\nThe above example sets the environment variable `MYPROJECT_KEEPASS_PASSPHRASE` with user input using \nthe `getpass` Python module only if not already set (`override=false`). This environment value is then \nused as the `keepass` passphrase to open a Keepass file where values are then selected and exported \ninto the shell environment.\n\nSubstantially more complex env-alias definitions can be created.\n\nBy naming your env-aliases with an easy to remember prefix such as `env-` it is also possible to \nleverage shell **tab-completion** thus making it easier to find the env-alias definitions created \nfor your project or other use-case situation.\n\n## Features\nEnv Alias is enormously useful in working with large sets of environment variables from remote, encrypted \nor otherwise secured data-sources.\n \n* Data sources: **local-files**, **http-remote** and stdout from an **exec** command-line.\n* Source formats supported: **JSON**, **YAML**, **Keepass**, **Ansible Vault**, **Plaintext** and **Ini**-config.\n* Select values using **jq** style selectors, **xpath** style selectors or **line-numbers**.\n* \ud83d\udca5 Additional special handling for **Ansible Vault Password Files** that makes credential handling for **Ansible Vault** files substantially easier with reduced exposure risks. \ud83d\udca5 \n* Self reference environment values in the definition file or from the existing system environment.\n* Define variables with a `null` name to prevent them being exported into the system environment while still being available for self-reference within the env-alias definition; this is helpful when working with sensitive values that should not be available through the system environment.\n* Ability to use `exec` commands to setup other project prerequisites or other project start conditions.\n* Debug mode output to STDERR.\n* Easy installation from PyPI.\n* Plenty of documentation and examples - [https://env-alias.readthedocs.io](https://env-alias.readthedocs.io)\n\n## Installation\nPip or pipx should be fine, we prefer pipx these days.\n```shell\npipx install env-alias\n```\n\n## Usage\nThis tool is typically invoked using an entry in `.bash_aliases` with an entry of the form:-\n```shell\nsource <(env-alias ~/projects/awesome/env-awesome-vars.yml)\n```\n\nThis simple `.bash_aliases` one-line entry creates the alias `env-awesome-project` by inferring the \nalias-name from the filename, where this alias then invokes env-alias to set environment values \ndefined in `env-awesome-project.yml` \n\nAlternatively, you might want to create the alias `awesome-envvars` which you could do as per - \n```shell\nsource <(env-alias awesome-envvars ~/projects/awesome/env-awesome-vars.yml)\n```\n\n\n## Project\n* Github - [github.com/ndejong/env-alias](https://github.com/ndejong/env-alias)\n* PyPI - [pypi.python.org/pypi/env-alias](https://pypi.python.org/pypi/env-alias/)\n* ReadTheDocs - [env-alias.readthedocs.io](https://env-alias.readthedocs.io)\n\n---\nCopyright © (2020-2024) Nicholas de Jong\n\n",
"bugtrack_url": null,
"license": "BSD-2-Clause",
"summary": "Powerful helper utility to create shell alias commands to easily set collections of environment variables often with secret values from a variety of data-sources and data-formats.",
"version": "0.5.3",
"project_urls": {
"Bug Tracker": "https://github.com/ndejong/env-alias/issues",
"Documentation": "https://env-alias.readthedocs.io/",
"Homepage": "https://github.com/ndejong/env-alias",
"Repository": "https://github.com/ndejong/env-alias"
},
"split_keywords": [
"env-alias",
" shell",
" env",
" alias",
" bash"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "362816b31f198f2892e3d04a317230e05b95a172d10f889da9311cce96b9cfcd",
"md5": "6b4ce9d1729b5ce6b285ffd5a09b920b",
"sha256": "f76bbeb44bcf88d01e2d4344030151a70dba297a47d7e569096644358a5fc291"
},
"downloads": -1,
"filename": "env_alias-0.5.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6b4ce9d1729b5ce6b285ffd5a09b920b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 15514,
"upload_time": "2024-09-28T07:38:02",
"upload_time_iso_8601": "2024-09-28T07:38:02.515127Z",
"url": "https://files.pythonhosted.org/packages/36/28/16b31f198f2892e3d04a317230e05b95a172d10f889da9311cce96b9cfcd/env_alias-0.5.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d50cd1e1f3cc70441ea50d401fc8a7da01feafc91fed7ee0883d6d10d87e6037",
"md5": "6687798dfdb65ee5a10f935cb094d101",
"sha256": "aebc06eef3c3832aea7116282dcbaf26a6c966aabe765441849b7e3e171346e4"
},
"downloads": -1,
"filename": "env_alias-0.5.3.tar.gz",
"has_sig": false,
"md5_digest": "6687798dfdb65ee5a10f935cb094d101",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 14519,
"upload_time": "2024-09-28T07:38:04",
"upload_time_iso_8601": "2024-09-28T07:38:04.218400Z",
"url": "https://files.pythonhosted.org/packages/d5/0c/d1e1f3cc70441ea50d401fc8a7da01feafc91fed7ee0883d6d10d87e6037/env_alias-0.5.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-28 07:38:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ndejong",
"github_project": "env-alias",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "env-alias"
}