Skip to content

Instantly share code, notes, and snippets.

@anryko
Last active March 8, 2018 12:27
Show Gist options
  • Save anryko/a93fa477e3aafccfc6b1d9a991e34b76 to your computer and use it in GitHub Desktop.
Save anryko/a93fa477e3aafccfc6b1d9a991e34b76 to your computer and use it in GitHub Desktop.
Andible filter env vars for docker.
- set_fact:
set_filter: 'aws_'
# set_envs: [{ 'AWS_PROFILE': <value>}, {'AWS_REGION': <value>}, ...]
- set_fact:
set_envs: "{{ set_envs | d([]) | union([{ item.split('=', 1)[0]: item.split('=', 1)[1] }]) }}"
when: item.startswith(set_filter | upper)
with_items: "{{ lookup('pipe', 'env').split('\n') }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment