Skip to content

Instantly share code, notes, and snippets.

@maxamillion
Last active October 25, 2022 21:09
Show Gist options
  • Save maxamillion/3e915dd8dbbb59cab22087ee10f60f2c to your computer and use it in GitHub Desktop.
Save maxamillion/3e915dd8dbbb59cab22087ee10f60f2c to your computer and use it in GitHub Desktop.
fun with slurped json
{
"data":
{
"foobar": "barfoo",
"linux": "isthebest"
}
}
---
- 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