Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (19 sloc) 706 Bytes
- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Read JSON file (can also be a variable).
shell: cat files/example.json
register: json
- name: Get simple value.
set_fact:
simple_value: "{{ (json.stdout | from_json).example_simple.name }}"
- name: Simple debug.
debug:
msg: "{{ simple_value }}"
- name: Get foo value.
set_fact:
foo_value: "{{ (json.stdout | from_json).example_list | map(attribute='foo') | list }}"
- name: Jinja list debug, printing out the list as comma seperated.
debug:
msg: "{% for each in foo_value %}{{ each }}{% if not loop.last %},{% endif %}{% endfor %}"
You can’t perform that action at this time.