Last active
October 25, 2022 21:09
-
-
Save maxamillion/3e915dd8dbbb59cab22087ee10f60f2c to your computer and use it in GitHub Desktop.
fun with slurped json
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
{ | |
"data": | |
{ | |
"foobar": "barfoo", | |
"linux": "isthebest" | |
} | |
} |
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: testing | |
hosts: localhost | |
tasks: | |
- name: slurp the json file content as base64 (because reasons) | |
ansible.builtin.slurp: | |
src: "/tmp/foo.json" | |
register: slurped_file | |
- name: grab the value of the "linux" key | |
set_fact: | |
raw_json: "{{ slurped_file.content | b64decode }}" | |
linux_key: "{{ (slurped_file.content | b64decode | from_json).data.linux }}" | |
- debug: var=raw_json | |
- debug: var=linux_key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment