Thank you all for your help and support. Yes, now it's work.
@Angel: I'm really newbie in this kind of scripting and I do mix it up a little bit with these format. If you have a clever tutorial, I want it ;) Regards, J On Wednesday, February 19, 2020 at 1:20:18 AM UTC+1, Angel Rengifo Cancino wrote: > > Hello: > > On Tue, Feb 18, 2020 at 7:39 AM Jerome Meyer <[email protected] > <javascript:>> wrote: > >> I've created one example.fson file : >> # cat files/example.json >> json_example: | >> { >> "example_simple": { >> "name": "simple", >> "foo": "value", >> "item": "this" >> }, >> } >> >> Your JSON has an incorrect syntax. This is how should look like: > > { > "json_example": { > "example_simple": { > "name": "simple", > "foo": "value", > "item": "this" > } > } > } > > This way, your playbook just runs fine: > > - shell: cat example.json > register: result > > - set_fact: > myvar: "{{ result.stdout | from_json }}" > > - debug: var=myvar > > which produces this output: > > TASK [shell] > ************************************************************************************************************************************************************ > changed: [localhost] > > TASK [set_fact] > ********************************************************************************************************************************************************* > ok: [localhost] > > TASK [debug] > ************************************************************************************************************************************************************ > ok: [localhost] => { > "myvar": { > "json_example": { > "example_simple": { > "foo": "value", > "item": "this", > "name": "simple" > } > } > } > } > > You can use this to parse your JSON files: > > $ python -m json.tool < example.json > > As Dick Visser said, it seems you're mixed some kind of YAML+JSON content > which invalidates it at all > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d700b40d-3c42-4736-bd73-8afb454ea864%40googlegroups.com.
