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

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

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

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' > >

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:

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 |

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',

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

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

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 |

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'

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

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

[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 ~