How can I add new line characters to Ansible variable mailbody. This mailbody variable is used for mail module's body attribute.
I tried the below from suggestions but none of them works.
1.
- set_fact:
mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + PROFILE_NAME ~ '\n\nSERVER_NAME:' + SERVER_NAME ~ '\n\nNODE_NAME:' + NODE_NAME ~ '\n\n\n\n' }}"
2.
mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + PROFILE_NAME ~}} {{ 'SERVER_NAME:' + SERVER_NAME ~ }}\n\n{{'NODE_NAME:' + NODE_NAME ~ }}\n\n\n\n"
3.mailbody: | "{{ mailbody | default('') + 'PROFILE_NAME:' + PROFILE_NAME ~}}" "{{ 'SERVER_NAME:' + SERVER_NAME ~ }}" "{{'NODE_NAME:' + NODE_NAME ~ }}"
In the mail body i see '\n' instead of the new line charecter.Can you please suggest ?
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com.
- set_fact:
mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + PROFILE_NAME ~ \"\n\n\"'SERVER_NAME:' + SERVER_NAME ~ \"\n\n\"'NODE_NAME:' + NODE_NAME ~ \"\n\n\n\n\" }}"
I won't comment on whatever it is you're trying to do, but in any case you need to use double quotes around the newlines
On Wed, 3 Jun 2020 at 20:12, Shifa Shaikh <shif...@gmail.com> wrote:
How can I add new line characters to Ansible variable
mailbody. This mailbody variable is used for mail module's body attribute.
I tried the below from suggestions but none of them works.
1.
- set_fact: mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + PROFILE_NAME ~ '\n\nSERVER_NAME:' + SERVER_NAME ~ '\n\nNODE_NAME:' + NODE_NAME ~ '\n\n\n\n' }}"
2.
mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + PROFILE_NAME ~}} {{ 'SERVER_NAME:' + SERVER_NAME ~ }}\n\n{{'NODE_NAME:' + NODE_NAME ~ }}\n\n\n\n"3.mailbody: | "{{ mailbody | default('') + 'PROFILE_NAME:' + PROFILE_NAME ~}}" "{{ 'SERVER_NAME:' + SERVER_NAME ~ }}" "{{'NODE_NAME:' + NODE_NAME ~ }}"
In the mail body i see '\n' instead of the new line charecter.Can you please suggest ?--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/061717dc-af0d-2dd1-8b5a-ba5f4e34ac0f%40linuxia.de.
- copy
content: "{{ mailbody }}"
dest: /tmp/write.log
- name: Send mail
mail:
host: localhost:
port: 25
subject: :Hi"
body: "{{ mailbody }}"
from: m...@myshop.com
to: y...@yourmail.com
> <javascript:>>.
> > > To view this discussion on the web visit
> > > https://groups.google.com/d/msgid/ansible-project/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com
> > <https://groups.google.com/d/msgid/ansible-project/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com>
> > >
> >
> <https://groups.google.com/d/msgid/ansible-project/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com?utm_medium=email&utm_source=footer
> >
> <https://groups.google.com/d/msgid/ansible-project/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com?utm_medium=email&utm_source=footer>>.
> >
> >
> >
> > --
> > Ecommerce and Linux consulting + Perl and web application programming.
> > Debian and Sympa administration. Provisioning with Ansible.
> >
> > --
> > 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
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/ansible-project/ea570673-e541-4207-81c8-84d4353b8572%40googlegroups.com
> >
> <https://groups.google.com/d/msgid/ansible-project/ea570673-e541-4207-81c8-84d4353b8572%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> 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
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/061717dc-af0d-2dd1-8b5a-ba5f4e34ac0f%40linuxia.de.
>
> --
> 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
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwOeMNKXRwOtnWdo-b_RnqOUhv-Nobi4ED6WDpzKj3HHzg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwOeMNKXRwOtnWdo-b_RnqOUhv-Nobi4ED6WDpzKj3HHzg%40mail.gmail.com.