line break with lookup

18 views
Skip to first unread message

Karther

unread,
Jun 28, 2019, 4:24:17 AM6/28/19
to Ansible Project
Hy all,

I have one file my_file with this content :

myfirstparaphrase

I have this task :

- set_fact:
  variable1: "{{ lookup('file', '/home/ansible/my_file') | replace(' ', '\n') }}"

I want that in the end of my phrase, there is line breack but this task not works ...

Someone have idea please community ansible ??! :)

Thanks,

Regards,

Punit Jain

unread,
Jun 28, 2019, 8:39:39 AM6/28/19
to ansible...@googlegroups.com
Are you looking for this . ?

set_fact:
        variable1: "{{lookup('file', 'my_file') if '\n' in lookup('file', 'my_file') else lookup('file', 'my_file') + '\n'}}"

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b6eb265d-50b6-4cf9-8e5a-41aaafc96514%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Karther

unread,
Jun 28, 2019, 9:32:49 AM6/28/19
to Ansible Project
Hy,

I have try this issue, but  +'\n' is write at the end of my file and he not play role of "line break" ...
I don't know if do you understand ?? :)

Thanks for your answer ;)

Regards,


Le vendredi 28 juin 2019 14:39:39 UTC+2, Punit Jain a écrit :
Are you looking for this . ?

set_fact:
        variable1: "{{lookup('file', 'my_file') if '\n' in lookup('file', 'my_file') else lookup('file', 'my_file') + '\n'}}"

On Fri, 28 Jun 2019 at 13:54, Karther <ryadmo...@gmail.com> wrote:
Hy all,

I have one file my_file with this content :

myfirstparaphrase

I have this task :

- set_fact:
  variable1: "{{ lookup('file', '/home/ansible/my_file') | replace(' ', '\n') }}"

I want that in the end of my phrase, there is line breack but this task not works ...

Someone have idea please community ansible ??! :)

Thanks,

Regards,

--
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 ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages