On 28.07.2019 18:11, jean-christophe manciot wrote:
> A call to ansible uri module returns a *multi-line string*:
> 
> - set_fact:
>          fact: "{{ return_uri_json.body }}"
> 
> ok: [target] => {
>      "ansible_facts": {
>          "fact": "line_1\nline_2\nline_3\nline_4\n"
>      },
>      "changed": false
> }
> 
> 
> The goal is to convert "fact" into:
> - "line_1"
> - "line_2"
> - "line_3"
> - "line_4"
> 
> I couldn't find any jinja2 filter for that task. Maybe I've missed
> something.
> Any suggestion?

You can use Python splitlines

{{ return_uri_json.body.splitlines() }}


-- 
Kai Stian Olstad

-- 
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/c4d92dc4-5f4e-7e1d-be2a-bff5d2a0afbd%40olstad.com.

Reply via email to