On Tue, 31 Dec 2019 00:34:57 -0800 (PST)
Karther <[email protected]> wrote:

> No I have this result with this task :
> "msg": "exactly as you see\nwill appear these three\nlines of poetry\n"
> 
> Le jeudi 12 décembre 2019 22:48:49 UTC+1, j1f0x a écrit :
> > maybe you try this:
> > include_newlines: |
> >             exactly as you see
> >             will appear these three
> >             lines of poetry

The playbook below is self-explaining

- hosts: localhost
  vars:
    msg: |
      exactly as you see
      will appear these three
      lines of poetry
  tasks:
    - debug:
        msg: "{{ msg }}"
    - debug:
        msg: "{{ msg.split('\n') }}"
    - debug:
        msg: "{{ msg.split('\n')[:-1] }}"

gives

ok: [localhost] => {
    "msg": "exactly as you see\nwill appear these three\nlines of poetry\n"
}

ok: [localhost] => { "msg": [
        "exactly as you see", 
        "will appear these three", 
        "lines of poetry", 
        ""
    ]
}

ok: [localhost] => { "msg": [
        "exactly as you see", 
        "will appear these three", 
        "lines of poetry"
    ]
}

HTH,

        -vlado

-- 
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/20191231102644.6d6f23eb%40gmail.com.

Attachment: pgpyheK8cryeL.pgp
Description: OpenPGP digital signature

Reply via email to