Last active
October 9, 2018 15:24
-
-
Save agaffney/e12fa01adeb2a4698ee7db8e60fecfe2 to your computer and use it in GitHub Desktop.
Ansible tasks to source remote file and return resulting env vars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Source file and return env vars | |
shell: > | |
. /path/to/foo.env; | |
{{ ansible_python_interpreter | default('python') }} -c | |
'from __future__ import print_function; import os, json; print(json.dumps(dict(os.environ)))' | |
register: source_env_vars_output | |
- name: Create var from JSON | |
set_fact: | |
source_env_vars: '{{ source_env_vars_output.stdout | from_json }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment