Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-04 Thread Dick Visser
On Thu, 4 Jun 2020 at 14:07, Shifa Shaikh  wrote:
>
> Dick Hi,
>
> That was a typo; however, the problem remains!! Writing to a file is all good 
> with newline while writing to email body does not translate "\n" as new line 
> !! Could this be a bug? Kindly suggest.

Just tried it out and it works fine here.
Can you show again the complete playbook? Including the task where the
body is generated?
That must be the issue I think.



-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwNouf6LhHh7EouUEFjtF3u47%2BOz70oxm2EL9-eaCoku5A%40mail.gmail.com.


Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-04 Thread Shifa Shaikh
Dick Hi,

That was a typo; however, the problem remains!! Writing to a file is all
good with newline while writing to email body does not translate "\n" as
new line !! Could this be a bug? Kindly suggest.

On Thu, Jun 4, 2020 at 3:37 PM Dick Visser  wrote:

> On Thu, 4 Jun 2020 at 10:50, Shifa Shaikh  wrote:
> >
> > I see the problem is different than the direction we are debugging.
> >
> > When i write the variable to a file i see new lines but when the
> variable  assigned to email body it does not interpolate the new line
> instead prints '\n'
> >
> >- copy
> > content: "{{ mailbody }}"
> > dest: /tmp/write.log
> >
> >
> >
> > - name: Send mail
> >   mail:
> >   host: localhost:
>
> There is an extra ':' here?
>
> >   port: 25
> >   subject: :Hi"
>
> There is an extra ':' here?
>
> >   body: "{{ mailbody }}"
> >   from: m...@myshop.com
> >   to: y...@yourmail.com
>
>
> > Can you please suggest?
>
> You already put two errors in your task which prevent it from running
> correctly.
> So in that light, i'm wondering if your actual task does, in fact,
> contain more differences than what you've posted here.
>
> Also, "prints '\n'" indicates that you're echoing? and not mailing?
>
>
>
> >
> > On Thursday, June 4, 2020 at 1:26:56 PM UTC+5:30, Stefan Hornburg
> (Racke) wrote:
> >>
> >> On 6/4/20 8:54 AM, Shifa Shaikh wrote:
> >> > I tried multiline too as below, but that too fails
> >> >
> >> >mailbody: |
> >> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME
> }}" + "\n"
> >> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
> >> >
> >>
> >> Please try:
> >>
> >> mailbody: |
> >>   {{ mailbody | default('') }}PROFILE_NAME: {{ PROFILE_NAME }}
> >>   SERVER_NAME: + {{ SERVER_NAME }}
> >>
> >> Regards
> >>  Racke
> >>
> >> >
> >>
> >> > Output:
> >> > ['"PROFILE_NAME: SPROD01" + "[file://\\n"\n]\\n"\n"SERVER_NAME:
> SPROD01SRV01"\n', '"PROFILE_NAME: SPROD02" +
> >> > "[file://\\n"\n]\\n"\n"SERVER_NAME: SPROD02SRV02"\n']
> >> >
> >> > Also tried:
> >> >
> >> >mailbody: |
> >> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME
> }}"
> >> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
> >> >
> >> > and
> >> >
> >> >mailbody: |
> >> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME
> }}" + "\\n"
> >> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
> >> >
> >> > On Thu, Jun 4, 2020 at 11:38 AM Stefan Hornburg (Racke) <
> ra...@linuxia.de > wrote:
> >> >
> >> > On 6/4/20 7:21 AM, Shifa Shaikh wrote:
> >> > > Stephan Hi,
> >> > >
> >> > > The article does not discuss newline inside parenthesis `{{`
> inside a variable definition. That is where I have no
> >> > clue.
> >> >
> >> >
> >> > Hello Shifa,
> >> >
> >> > parenthesis are fine inside multiline YAML.
> >> >
> >> > Regards
> >> >  Racke
> >> >
> >> > >
> >> > > On Thursday, June 4, 2020 at 10:31:41 AM UTC+5:30, Stefan
> Hornburg (Racke) wrote:
> >> > >
> >> > > On 6/4/20 6:41 AM, Shifa Shaikh wrote:
> >> > > > I tried all of these but have no clue to a solution.
> >> > > >
> >> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +
> PROFILE_NAME + "\n" + 'SERVER_NAME:' + SERVER_NAME
> >> > + "\n" +
> >> > > > 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}"
> >> > > >
> >> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +
> PROFILE_NAME + '\n' + 'SERVER_NAME:' + SERVER_NAME
> >> > + '\n' +
> >> > > > 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}"
> >> > > >
> >> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +
> PROFILE_NAME ~ }} \n + {{ 'SERVER_NAME:' +
> >> > SERVER_NAME ~
> >> > > }} +
> >> > > > \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\"
> >> > > >
> >> > > >
> >> > >
> >> > > Use multiline YAML: https://yaml-multiline.info/
> >> > >
> >> > > Regards
> >> > > Racke
> >> > >
> >> > >
> >> > > > On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa
> Shaikh wrote:
> >> > > >
> >> > > > @Dick VIsser Hi,
> >> > > >
> >> > > > Upon your suggestion, I tried something like this but
> it too does not work.
> >> > > >
> >> > > > |
> >> > > >-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\" }}"
> >> > > > |
> >> > > >
> >> > > > Can someone please suggest?
> >> > > >
> >> > > > On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30,
> Dick Visser wrote:
> >> > 

Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-04 Thread Shifa Shaikh
@Dick Hi,

That was a typo the problem remains writing to a file is all good with
newlines while writing to email body does not translate "\n" as new line !!
Could this be a bug ?

On Thu, Jun 4, 2020 at 3:37 PM Dick Visser  wrote:

> On Thu, 4 Jun 2020 at 10:50, Shifa Shaikh  wrote:
> >
> > I see the problem is different than the direction we are debugging.
> >
> > When i write the variable to a file i see new lines but when the
> variable  assigned to email body it does not interpolate the new line
> instead prints '\n'
> >
> >- copy
> > content: "{{ mailbody }}"
> > dest: /tmp/write.log
> >
> >
> >
> > - name: Send mail
> >   mail:
> >   host: localhost:
>
> There is an extra ':' here?
>
> >   port: 25
> >   subject: :Hi"
>
> There is an extra ':' here?
>
> >   body: "{{ mailbody }}"
> >   from: m...@myshop.com
> >   to: y...@yourmail.com
>
>
> > Can you please suggest?
>
> You already put two errors in your task which prevent it from running
> correctly.
> So in that light, i'm wondering if your actual task does, in fact,
> contain more differences than what you've posted here.
>
> Also, "prints '\n'" indicates that you're echoing? and not mailing?
>
>
>
> >
> > On Thursday, June 4, 2020 at 1:26:56 PM UTC+5:30, Stefan Hornburg
> (Racke) wrote:
> >>
> >> On 6/4/20 8:54 AM, Shifa Shaikh wrote:
> >> > I tried multiline too as below, but that too fails
> >> >
> >> >mailbody: |
> >> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME
> }}" + "\n"
> >> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
> >> >
> >>
> >> Please try:
> >>
> >> mailbody: |
> >>   {{ mailbody | default('') }}PROFILE_NAME: {{ PROFILE_NAME }}
> >>   SERVER_NAME: + {{ SERVER_NAME }}
> >>
> >> Regards
> >>  Racke
> >>
> >> >
> >>
> >> > Output:
> >> > ['"PROFILE_NAME: SPROD01" + "[file://\\n"\n]\\n"\n"SERVER_NAME:
> SPROD01SRV01"\n', '"PROFILE_NAME: SPROD02" +
> >> > "[file://\\n"\n]\\n"\n"SERVER_NAME: SPROD02SRV02"\n']
> >> >
> >> > Also tried:
> >> >
> >> >mailbody: |
> >> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME
> }}"
> >> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
> >> >
> >> > and
> >> >
> >> >mailbody: |
> >> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME
> }}" + "\\n"
> >> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
> >> >
> >> > On Thu, Jun 4, 2020 at 11:38 AM Stefan Hornburg (Racke) <
> ra...@linuxia.de > wrote:
> >> >
> >> > On 6/4/20 7:21 AM, Shifa Shaikh wrote:
> >> > > Stephan Hi,
> >> > >
> >> > > The article does not discuss newline inside parenthesis `{{`
> inside a variable definition. That is where I have no
> >> > clue.
> >> >
> >> >
> >> > Hello Shifa,
> >> >
> >> > parenthesis are fine inside multiline YAML.
> >> >
> >> > Regards
> >> >  Racke
> >> >
> >> > >
> >> > > On Thursday, June 4, 2020 at 10:31:41 AM UTC+5:30, Stefan
> Hornburg (Racke) wrote:
> >> > >
> >> > > On 6/4/20 6:41 AM, Shifa Shaikh wrote:
> >> > > > I tried all of these but have no clue to a solution.
> >> > > >
> >> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +
> PROFILE_NAME + "\n" + 'SERVER_NAME:' + SERVER_NAME
> >> > + "\n" +
> >> > > > 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}"
> >> > > >
> >> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +
> PROFILE_NAME + '\n' + 'SERVER_NAME:' + SERVER_NAME
> >> > + '\n' +
> >> > > > 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}"
> >> > > >
> >> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +
> PROFILE_NAME ~ }} \n + {{ 'SERVER_NAME:' +
> >> > SERVER_NAME ~
> >> > > }} +
> >> > > > \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\"
> >> > > >
> >> > > >
> >> > >
> >> > > Use multiline YAML: https://yaml-multiline.info/
> >> > >
> >> > > Regards
> >> > > Racke
> >> > >
> >> > >
> >> > > > On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa
> Shaikh wrote:
> >> > > >
> >> > > > @Dick VIsser Hi,
> >> > > >
> >> > > > Upon your suggestion, I tried something like this but
> it too does not work.
> >> > > >
> >> > > > |
> >> > > >-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\" }}"
> >> > > > |
> >> > > >
> >> > > > Can someone please suggest?
> >> > > >
> >> > > > On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30,
> Dick Visser wrote:
> >> > > >
> >> > > 

Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-04 Thread Dick Visser
On Thu, 4 Jun 2020 at 10:50, Shifa Shaikh  wrote:
>
> I see the problem is different than the direction we are debugging.
>
> When i write the variable to a file i see new lines but when the variable  
> assigned to email body it does not interpolate the new line instead prints 
> '\n'
>
>- copy
> content: "{{ mailbody }}"
> dest: /tmp/write.log
>
>
>
> - name: Send mail
>   mail:
>   host: localhost:

There is an extra ':' here?

>   port: 25
>   subject: :Hi"

There is an extra ':' here?

>   body: "{{ mailbody }}"
>   from: m...@myshop.com
>   to: y...@yourmail.com


> Can you please suggest?

You already put two errors in your task which prevent it from running correctly.
So in that light, i'm wondering if your actual task does, in fact,
contain more differences than what you've posted here.

Also, "prints '\n'" indicates that you're echoing? and not mailing?



>
> On Thursday, June 4, 2020 at 1:26:56 PM UTC+5:30, Stefan Hornburg (Racke) 
> wrote:
>>
>> On 6/4/20 8:54 AM, Shifa Shaikh wrote:
>> > I tried multiline too as below, but that too fails
>> >
>> >mailbody: |
>> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}" 
>> > + "\n"
>> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
>> >
>>
>> Please try:
>>
>> mailbody: |
>>   {{ mailbody | default('') }}PROFILE_NAME: {{ PROFILE_NAME }}
>>   SERVER_NAME: + {{ SERVER_NAME }}
>>
>> Regards
>>  Racke
>>
>> >
>>
>> > Output:
>> > ['"PROFILE_NAME: SPROD01" + "[file://\\n"\n]\\n"\n"SERVER_NAME: 
>> > SPROD01SRV01"\n', '"PROFILE_NAME: SPROD02" +
>> > "[file://\\n"\n]\\n"\n"SERVER_NAME: SPROD02SRV02"\n']
>> >
>> > Also tried:
>> >
>> >mailbody: |
>> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}"
>> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
>> >
>> > and
>> >
>> >mailbody: |
>> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}" 
>> > + "\\n"
>> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
>> >
>> > On Thu, Jun 4, 2020 at 11:38 AM Stefan Hornburg (Racke) > > > wrote:
>> >
>> > On 6/4/20 7:21 AM, Shifa Shaikh wrote:
>> > > Stephan Hi,
>> > >
>> > > The article does not discuss newline inside parenthesis `{{` inside 
>> > a variable definition. That is where I have no
>> > clue.
>> >
>> >
>> > Hello Shifa,
>> >
>> > parenthesis are fine inside multiline YAML.
>> >
>> > Regards
>> >  Racke
>> >
>> > >
>> > > On Thursday, June 4, 2020 at 10:31:41 AM UTC+5:30, Stefan Hornburg 
>> > (Racke) wrote:
>> > >
>> > > On 6/4/20 6:41 AM, Shifa Shaikh wrote:
>> > > > I tried all of these but have no clue to a solution.
>> > > >
>> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  
>> > PROFILE_NAME + "\n" + 'SERVER_NAME:' + SERVER_NAME
>> > + "\n" +
>> > > > 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}"
>> > > >
>> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  
>> > PROFILE_NAME + '\n' + 'SERVER_NAME:' + SERVER_NAME
>> > + '\n' +
>> > > > 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}"
>> > > >
>> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  
>> > PROFILE_NAME ~ }} \n + {{ 'SERVER_NAME:' +
>> > SERVER_NAME ~
>> > > }} +
>> > > > \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\"
>> > > >
>> > > >
>> > >
>> > > Use multiline YAML: https://yaml-multiline.info/
>> > >
>> > > Regards
>> > > Racke
>> > >
>> > >
>> > > > On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh 
>> > wrote:
>> > > >
>> > > > @Dick VIsser Hi,
>> > > >
>> > > > Upon your suggestion, I tried something like this but it 
>> > too does not work.
>> > > >
>> > > > |
>> > > >-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\" }}"
>> > > > |
>> > > >
>> > > > Can someone please suggest?
>> > > >
>> > > > On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick 
>> > Visser wrote:
>> > > >
>> > > > 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 
>> > mailto:shif...@gmail.com>> wrote:
>> > > >
>> > > > How can I add new line characters to Ansible 
>> > variable |mailbody. This mailbody variable is used
>> > for 

Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-04 Thread Shifa Shaikh
I see the problem is different than the direction we are debugging. 

When i write the variable to a file i see new lines but when the variable  
assigned to email body it does not interpolate the new line instead prints 
'\n'

   - 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

Can you please suggest?

On Thursday, June 4, 2020 at 1:26:56 PM UTC+5:30, Stefan Hornburg (Racke) 
wrote:
>
> On 6/4/20 8:54 AM, Shifa Shaikh wrote: 
> > I tried multiline too as below, but that too fails 
> > 
> >mailbody: | 
> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME 
> }}" + "\n" 
> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}" 
> > 
>
> Please try: 
>
> mailbody: | 
>   {{ mailbody | default('') }}PROFILE_NAME: {{ PROFILE_NAME }} 
>   SERVER_NAME: + {{ SERVER_NAME }} 
>
> Regards 
>  Racke 
>
> > 
>
> > Output: 
> > ['"PROFILE_NAME: SPROD01" + "[file://\\n"\n]\\n"\n"SERVER_NAME: 
> SPROD01SRV01"\n', '"PROFILE_NAME: SPROD02" + 
> > "[file://\\n"\n]\\n"\n"SERVER_NAME: SPROD02SRV02"\n'] 
> > 
> > Also tried: 
> > 
> >mailbody: | 
> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME 
> }}" 
> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}" 
> > 
> > and 
> > 
> >mailbody: | 
> >  "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME 
> }}" + "\\n" 
> >  "{{ 'SERVER_NAME: ' + SERVER_NAME }}" 
> > 
> > On Thu, Jun 4, 2020 at 11:38 AM Stefan Hornburg (Racke) <
> ra...@linuxia.de  > 
> wrote: 
> > 
> > On 6/4/20 7:21 AM, Shifa Shaikh wrote: 
> > > Stephan Hi,  
> > > 
> > > The article does not discuss newline inside parenthesis `{{` 
> inside a variable definition. That is where I have no 
> > clue. 
> > 
> > 
> > Hello Shifa, 
> > 
> > parenthesis are fine inside multiline YAML. 
> > 
> > Regards 
> >  Racke 
> > 
> > > 
> > > On Thursday, June 4, 2020 at 10:31:41 AM UTC+5:30, Stefan Hornburg 
> (Racke) wrote: 
> > > 
> > > On 6/4/20 6:41 AM, Shifa Shaikh wrote: 
> > > > I tried all of these but have no clue to a solution.  
> > > > 
> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + 
>  PROFILE_NAME + "\n" + 'SERVER_NAME:' + SERVER_NAME 
> > + "\n" + 
> > > > 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}" 
> > > > 
> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + 
>  PROFILE_NAME + '\n' + 'SERVER_NAME:' + SERVER_NAME 
> > + '\n' + 
> > > > 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}" 
> > > > 
> > > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + 
>  PROFILE_NAME ~ }} \n + {{ 'SERVER_NAME:' + 
> > SERVER_NAME ~ 
> > > }} + 
> > > > \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\" 
> > > > 
> > > > 
> > > 
> > > Use multiline YAML: https://yaml-multiline.info/ 
> > > 
> > > Regards 
> > > Racke 
> > > 
> > > 
> > > > On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa 
> Shaikh wrote: 
> > > > 
> > > > @Dick VIsser Hi,  
> > > > 
> > > > Upon your suggestion, I tried something like this but it 
> too does not work. 
> > > > 
> > > > | 
> > > >-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\" }}" 
> > > > | 
> > > > 
> > > > Can someone please suggest? 
> > > > 
> > > > On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick 
> Visser wrote: 
> > > > 
> > > > 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('') + 

Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-04 Thread Stefan Hornburg (Racke)
On 6/4/20 8:54 AM, Shifa Shaikh wrote:
> I tried multiline too as below, but that too fails
> 
>        mailbody: |
>          "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}" + 
> "\n"
>          "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
> 

Please try:

mailbody: |
  {{ mailbody | default('') }}PROFILE_NAME: {{ PROFILE_NAME }}
  SERVER_NAME: + {{ SERVER_NAME }}

Regards
 Racke

>

> Output:
> ['"PROFILE_NAME: SPROD01" + "[file://\\n"\n]\\n"\n"SERVER_NAME: 
> SPROD01SRV01"\n', '"PROFILE_NAME: SPROD02" +
> "[file://\\n"\n]\\n"\n"SERVER_NAME: SPROD02SRV02"\n']
> 
> Also tried:
> 
>        mailbody: |
>          "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}"
>          "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
> 
> and
> 
>        mailbody: |
>          "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}" + 
> "\\n"
>          "{{ 'SERVER_NAME: ' + SERVER_NAME }}"
> 
> On Thu, Jun 4, 2020 at 11:38 AM Stefan Hornburg (Racke)  > wrote:
> 
> On 6/4/20 7:21 AM, Shifa Shaikh wrote:
> > Stephan Hi, 
> >
> > The article does not discuss newline inside parenthesis `{{` inside a 
> variable definition. That is where I have no
> clue.
> 
> 
> Hello Shifa,
> 
> parenthesis are fine inside multiline YAML.
> 
> Regards
>          Racke
> 
> >
> > On Thursday, June 4, 2020 at 10:31:41 AM UTC+5:30, Stefan Hornburg 
> (Racke) wrote:
> >
> >     On 6/4/20 6:41 AM, Shifa Shaikh wrote:
> >     > I tried all of these but have no clue to a solution. 
> >     >
> >     > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  
> PROFILE_NAME + "\n" + 'SERVER_NAME:' + SERVER_NAME
> + "\n" +
> >     > 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}"
> >     >
> >     > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  
> PROFILE_NAME + '\n' + 'SERVER_NAME:' + SERVER_NAME
> + '\n' +
> >     > 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}"
> >     >
> >     > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  
> PROFILE_NAME ~ }} \n + {{ 'SERVER_NAME:' +
> SERVER_NAME ~
> >     }} +
> >     > \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\"
> >     >
> >     >
> >
> >     Use multiline YAML: https://yaml-multiline.info/
> >
> >     Regards
> >             Racke
> >
> >
> >     > On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh 
> wrote:
> >     >
> >     >     @Dick VIsser Hi, 
> >     >
> >     >     Upon your suggestion, I tried something like this but it too 
> does not work.
> >     >
> >     >     |
> >     >        -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\" }}"
> >     >     |
> >     >
> >     >     Can someone please suggest?
> >     >
> >     >     On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick 
> Visser wrote:
> >     >
> >     >         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 
> mailto: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 

Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-04 Thread Shifa Shaikh
I tried multiline too as below, but that too fails

   mailbody: |
 "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}" +
"\n"
 "{{ 'SERVER_NAME: ' + SERVER_NAME }}"

Output:
['"PROFILE_NAME: SPROD01" + "[file://\\n"\n]\\n"\n"SERVER_NAME:
SPROD01SRV01"\n', '"PROFILE_NAME: SPROD02" +
"[file://\\n"\n]\\n"\n"SERVER_NAME: SPROD02SRV02"\n']

Also tried:

   mailbody: |
 "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}"
 "{{ 'SERVER_NAME: ' + SERVER_NAME }}"

and

   mailbody: |
 "{{ mailbody | default('') + 'PROFILE_NAME: ' + PROFILE_NAME }}" +
"\\n"
 "{{ 'SERVER_NAME: ' + SERVER_NAME }}"

On Thu, Jun 4, 2020 at 11:38 AM Stefan Hornburg (Racke) 
wrote:

> On 6/4/20 7:21 AM, Shifa Shaikh wrote:
> > Stephan Hi,
> >
> > The article does not discuss newline inside parenthesis `{{` inside a
> variable definition. That is where I have no clue.
>
>
> Hello Shifa,
>
> parenthesis are fine inside multiline YAML.
>
> Regards
>  Racke
>
> >
> > On Thursday, June 4, 2020 at 10:31:41 AM UTC+5:30, Stefan Hornburg
> (Racke) wrote:
> >
> > On 6/4/20 6:41 AM, Shifa Shaikh wrote:
> > > I tried all of these but have no clue to a solution.
> > >
> > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +
>  PROFILE_NAME + "\n" + 'SERVER_NAME:' + SERVER_NAME + "\n" +
> > > 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}"
> > >
> > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +
>  PROFILE_NAME + '\n' + 'SERVER_NAME:' + SERVER_NAME + '\n' +
> > > 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}"
> > >
> > > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +
>  PROFILE_NAME ~ }} \n + {{ 'SERVER_NAME:' + SERVER_NAME ~
> > }} +
> > > \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\"
> > >
> > >
> >
> > Use multiline YAML: https://yaml-multiline.info/
> >
> > Regards
> > Racke
> >
> >
> > > On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh
> wrote:
> > >
> > > @Dick VIsser Hi,
> > >
> > > Upon your suggestion, I tried something like this but it too
> does not work.
> > >
> > > |
> > >-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\" }}"
> > > |
> > >
> > > Can someone please suggest?
> > >
> > > On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick
> Visser wrote:
> > >
> > > 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
> > <
> https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com
> >
> > >
> > <
> https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com?utm_medium=email_source=footer
> >

Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-04 Thread Stefan Hornburg (Racke)
On 6/4/20 7:21 AM, Shifa Shaikh wrote:
> Stephan Hi, 
> 
> The article does not discuss newline inside parenthesis `{{` inside a 
> variable definition. That is where I have no clue.


Hello Shifa,

parenthesis are fine inside multiline YAML.

Regards
 Racke

> 
> On Thursday, June 4, 2020 at 10:31:41 AM UTC+5:30, Stefan Hornburg (Racke) 
> wrote:
> 
> On 6/4/20 6:41 AM, Shifa Shaikh wrote:
> > I tried all of these but have no clue to a solution. 
> >
> > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME 
> + "\n" + 'SERVER_NAME:' + SERVER_NAME + "\n" +
> > 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}"
> >
> > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME 
> + '\n' + 'SERVER_NAME:' + SERVER_NAME + '\n' +
> > 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}"
> >
> > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME 
> ~ }} \n + {{ 'SERVER_NAME:' + SERVER_NAME ~
> }} +
> > \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\"
> >
> >
> 
> Use multiline YAML: https://yaml-multiline.info/
> 
> Regards
>         Racke
> 
> 
> > On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh wrote:
> >
> >     @Dick VIsser Hi, 
> >
> >     Upon your suggestion, I tried something like this but it too does 
> not work.
> >
> >     |
> >        -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\" }}"
> >     |
> >
> >     Can someone please suggest?
> >
> >     On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick Visser 
> wrote:
> >
> >         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  
> 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
> 
> 
> >            
> 
>  
> >.
> 
> >
> >         --
> >         Sent from a mobile device - please excuse the brevity, spelling 
> and punctuation.
> >
> > --
> > 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/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com
> 
> 
> >
> 
> 

Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Shifa Shaikh
Stephan Hi, 

The article does not discuss newline inside parenthesis `{{` inside a 
variable definition. That is where I have no clue.

On Thursday, June 4, 2020 at 10:31:41 AM UTC+5:30, Stefan Hornburg (Racke) 
wrote:
>
> On 6/4/20 6:41 AM, Shifa Shaikh wrote: 
> > I tried all of these but have no clue to a solution.  
> > 
> > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + 
> "\n" + 'SERVER_NAME:' + SERVER_NAME + "\n" + 
> > 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}" 
> > 
> > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + 
> '\n' + 'SERVER_NAME:' + SERVER_NAME + '\n' + 
> > 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}" 
> > 
> > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~ 
> }} \n + {{ 'SERVER_NAME:' + SERVER_NAME ~ }} + 
> > \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\" 
> > 
> > 
>
> Use multiline YAML: https://yaml-multiline.info/ 
>
> Regards 
> Racke 
>
>
> > On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh wrote: 
> > 
> > @Dick VIsser Hi,  
> > 
> > Upon your suggestion, I tried something like this but it too does 
> not work. 
> > 
> > | 
> >-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\" }}" 
> > | 
> > 
> > Can someone please suggest? 
> > 
> > On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick Visser 
> wrote: 
> > 
> > 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  
> 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
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
> > 
> > -- 
> > Sent from a mobile device - please excuse the brevity, spelling 
> and punctuation. 
> > 
> > -- 
> > 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   ansible-project+unsubscr...@googlegroups.com >. 
> > 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?utm_medium=email_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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ea570673-e541-4207-81c8-84d4353b8572%40googlegroups.com.


Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Stefan Hornburg (Racke)
On 6/4/20 6:41 AM, Shifa Shaikh wrote:
> I tried all of these but have no clue to a solution. 
> 
> mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + "\n" 
> + 'SERVER_NAME:' + SERVER_NAME + "\n" +
> 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}"
> 
> mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + '\n' 
> + 'SERVER_NAME:' + SERVER_NAME + '\n' +
> 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}"
> 
> mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~ }} 
> \n + {{ 'SERVER_NAME:' + SERVER_NAME ~ }} +
> \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\"
> 
> 

Use multiline YAML: https://yaml-multiline.info/

Regards
Racke


> On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh wrote:
> 
> @Dick VIsser Hi, 
> 
> Upon your suggestion, I tried something like this but it too does not 
> work.
> 
> |
>    -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\" }}"
> |
> 
> Can someone please suggest?
> 
> On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick Visser wrote:
> 
> 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  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
> 
> .
> 
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
> 
> -- 
> 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-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com
> .


-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9151b720-fc60-3fae-cf2f-dda46ec4f711%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Shifa Shaikh
I tried all of these but have no clue to a solution. 

mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + 
"\n" + 'SERVER_NAME:' + SERVER_NAME + "\n" + 'NODE_NAME:' +  NODE_NAME + 
"\n\n\n\n\" }}"

mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + 
'\n' + 'SERVER_NAME:' + SERVER_NAME + '\n' + 'NODE_NAME:' +  NODE_NAME + 
'\n\n\n\n\' }}"

mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~ }} 
\n + {{ 'SERVER_NAME:' + SERVER_NAME ~ }} + \n + {{ 'NODE_NAME:' + 
 NODE_NAME ~ }} \n\n\n\n\"


On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh wrote:
>
> @Dick VIsser Hi, 
>
> Upon your suggestion, I tried something like this but it too does not work.
>
>- 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\" }}"
>
> Can someone please suggest?
>
> On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick Visser wrote:
>>
>> 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  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
>>>  
>>> 
>>> .
>>>
>> -- 
>> Sent from a mobile device - please excuse the brevity, spelling and 
>> punctuation.
>>
>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com.


Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Shifa Shaikh
@Dick VIsser Hi, 

Upon your suggestion, I tried something like this but it too does not work.

   - 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\" }}"

Can someone please suggest?

On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick Visser wrote:
>
> 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 > 
> 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
>>  
>> 
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9f876182-b951-4dc2-b6c6-dd6eb7b17c28%40googlegroups.com.


Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Dick Visser
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  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-project+unsubscr...@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
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwOWhpVoNHNdvfXzy7YXoWGnvw4MhN5FUE3H-fphPyHgpA%40mail.gmail.com.


[ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Shifa Shaikh


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-project+unsubscr...@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.