line break with lookup

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 ??! :slight_smile:

Thanks,

Regards,

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’}}”

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 ?? :slight_smile:

Thanks for your answer :wink:

Regards,