Re: [ansible-project] Ansible's plans regarding Python 2 EOL

2019-09-25 Thread Matt Martz
Nothing is changing from the Ansible perspective, which is why nothing has
been said. Ansible modules will still be required to support Python 2.6+
and controller code will still be required to support Python 2.7+.

This will likely continue until the EOL of Linux distributions that use
Python 2, such as RHEL7.

Red Hat will continue supporting Python 2 for RHEL7 until June 2024 iirc.

We may decide to drop python 2 support on the controller before RHEL7 EOL,
but should we make such a decision it will be announced at that time.

On Wed, Sep 25, 2019 at 9:05 AM Andrew Feller  wrote:

> We've all seen the warnings about Python 2 support ceasing on January 1st,
> 2020 from various projects  including pip
>  
> for
> months now.  I hoped Ansible blog
> 
> would have officially and proactively addressed the topic as this may
> require significant work for Ansible customers and the Ansible project over
> and above the early, minimal Python 3 support documentation
> 
>  including
> Ansible package distribution requiring python 2.x and potential migration
> guides for various Linux distributions if not Red Hat family at the least; 
> past
> threads
> 
> highlight tradeoffs over package versus pip installation.
>
> Does anyone have more information than what is cited above?
>
> --
> 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/3fd978ce-4f51-42ef-abed-c25504a9926f%40googlegroups.com
> 
> .
>
-- 
Matt Martz
@sivel
sivel.net

-- 
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/CAD8N0v9q3_tp625J5SoepSmr-f%2B%3DR-0iC_KzUs8JBbCnBuJrpw%40mail.gmail.com.


Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
There are no issues with the debug.

I rest this case with the experts of this forum to 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/eabf2637-c5be-4eb1-8246-426e015f1cb5%40googlegroups.com.


Re: [ansible-project] Re: Loading variables with data from REST

2019-09-25 Thread Brian Coca
you can also use a lookup

varname: '{{ lookup("url"  }}'


-- 
--
Brian Coca

-- 
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/CACVha7do4LO-_XF__0c2yQEQGSABH9PSQLWG8un5-VHg0Wy1Wg%40mail.gmail.com.


[ansible-project] Re: Ansible Fails to Restart Jetty on a remote host

2019-09-25 Thread Andre Gronwald
i think it is because the process is started within the ssh session opened 
by ansible, and if you close the session, the subprocesses will be stopped 
as well.

2 solutions:
1. use a system-service to restart jetty (don't know if it exists; maybe 
jetty.sh is doing this already, then the solution from jonathan would solve 
it))
2. use nohup at beginning of the command, to start the process outside of 
your ssh-session.

regards,
andre

Am Mittwoch, 25. September 2019 15:58:24 UTC+2 schrieb Madushan Chathuranga:
>
> Hi All,
>
> I'm trying to restart jetty using an ansible script
>
> bellow is a snippet from my script
>
> ---
>   - hosts: all
> tasks:
>
>
>  - name: start jetty
>command: sh jetty.sh restart
>args:
>  chdir: /apps/servers/jetty/bin
>
> my inventory file is 
> 10.0.18.225 ansible_user=appusr ansible_ssh_private_key_file=/home/ec2-
> user/key
>
>
> What happens is ansible is able to restart the jetty server as expected. 
> but once ansible script done it's execution jetty server stops.
> Any Ideas why this would happen. I don't have the luxury to start jetty as 
> a service here 'jetty start'. There are no error or sigkills in the jetty 
> logs. ansible also shows Jetty Start : OK in it's stdrr output. Would be 
> great if anyone could help me with this.
>
> Thanks.
>
>

-- 
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/7c1830af-89b7-481d-a465-059c5542e7d3%40googlegroups.com.


Re: [ansible-project] Ansible Fails to Restart Jetty on a remote host

2019-09-25 Thread Jonathan Lozada De La Matta
probably because you have sh on the command. Probably better if you pass
the whole directory to jetty.sh restart. Like /apps/servers/jetty/bin/jetty.sh
restart

On Wed, Sep 25, 2019 at 9:58 AM Madushan Chathuranga <
mchathuran...@gmail.com> wrote:

> Hi All,
>
> I'm trying to restart jetty using an ansible script
>
> bellow is a snippet from my script
>
> ---
>   - hosts: all
> tasks:
>
>
>  - name: start jetty
>command: sh jetty.sh restart
>args:
>  chdir: /apps/servers/jetty/bin
>
> my inventory file is
> 10.0.18.225 ansible_user=appusr ansible_ssh_private_key_file=/home/ec2-
> user/key
>
>
> What happens is ansible is able to restart the jetty server as expected.
> but once ansible script done it's execution jetty server stops.
> Any Ideas why this would happen. I don't have the luxury to start jetty as
> a service here 'jetty start'. There are no error or sigkills in the jetty
> logs. ansible also shows Jetty Start : OK in it's stdrr output. Would be
> great if anyone could help me with this.
>
> Thanks.
>
> --
> 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/ad1172d1-4cc0-4435-98e0-697fad20bfcb%40googlegroups.com
> 
> .
>
-- 

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Red Hat 

Senior Automation Practice Consultant & Automation CoP Manager

Join the Automation CoP! https://red.ht/autocop
@redhatjobs    redhatjobs
 @redhatjobs



-- 
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/CAFYJA%2B%2B4cUtJeT%3DoWL1HqZ1Ee7OBEdKVk1DkiyR85tKtfhNN%2BA%40mail.gmail.com.


[ansible-project] Ansible Fails to Restart Jetty on a remote host

2019-09-25 Thread Madushan Chathuranga
Hi All,

I'm trying to restart jetty using an ansible script

bellow is a snippet from my script

---
  - hosts: all
tasks:


 - name: start jetty
   command: sh jetty.sh restart
   args:
 chdir: /apps/servers/jetty/bin

my inventory file is 
10.0.18.225 ansible_user=appusr ansible_ssh_private_key_file=/home/ec2-user/
key


What happens is ansible is able to restart the jetty server as expected. 
but once ansible script done it's execution jetty server stops.
Any Ideas why this would happen. I don't have the luxury to start jetty as 
a service here 'jetty start'. There are no error or sigkills in the jetty 
logs. ansible also shows Jetty Start : OK in it's stdrr output. Would be 
great if anyone could help me with this.

Thanks.

-- 
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/ad1172d1-4cc0-4435-98e0-697fad20bfcb%40googlegroups.com.


Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Eric Jolley
Your debug statement appears to not be indebted properly.  

> On Sep 25, 2019, at 5:46 AM, Mohtashim S  wrote:
> 
> @ej does not help !
> 
>- debug:
>  var:
> USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"  with_items: "{{ command_result.stdout_lines }}"
> 
> 
> ERROR! 'var' is not a valid attribute for a Task
> 
> 
> The error appears to be in 
> '/app/axmw/Ansible/playbook/finacle_deployment/testinclude.yml.bkp': line 24, 
> column 6, but may
> be elsewhere in the file depending on the exact syntax problem.
> 
> 
> The offending line appears to be:
> 
> 
> 
> 
>- debug:
>  ^ here
> 
> 
> 
> 
>> On Wednesday, September 25, 2019 at 4:59:45 PM UTC+5:30, ej wrote:
>> Hello Mohtashim,
>> In your debug statement, try “var” instead of “vars”. 
>> 
>>> On Sep 25, 2019, at 5:13 AM, Mohtashim S  wrote:
>>> 
>>> There are two issues that i see. 
>>> 
>>> 1. I do not know how-to assign a variable USER value based on condition in 
>>> the loop 
>>> 
>>> Thus, instead of printing  msg: "{% if item.split('\t')[3] == 
>>> 'FrontEnd' %}user1{% else %}'user2'{% endif %}"  i wish to print "{{ USER 
>>> }}"
>>> 
>>> 2. 
>>> 
>>>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
>>> %}'user2'{% endif %}"  always prints user2. I guess it is not able to match 
>>> FrontEnd.
>>> 
>>> The issue could be with the if else statement or item.split('\t')[3] may 
>>> have some space due to which the match fails. 
>>> 
>>> Below is the current output for this playbook:
>>> 
>>>- debug:
>>>msg: "User was {{ item.split('\t')[3] }}"
>>>  with_items: "{{ command_result.stdout_lines }}"
>>> 
>>> 
>>>- debug:
>>>  vars:
>>>USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
>>> %}'user2'{% endif %}"
>>>msg: "User is {{ USER }}"
>>>  with_items: "{{ command_result.stdout_lines }}"
>>> 
>>>- debug:
>>>msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
>>> %}'user2'{% endif %}"
>>>  with_items: "{{ command_result.stdout_lines }}"
>>> 
>>> 
>>> 
>>> Output:
>>> 
 TASK [debug] 
 
 ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
 /was//testingjsp   FrontEnd) => {
 "msg": "User was FrontEnd"
 }
 ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
 2019-09-13 15:38 /fin/com/testingcom.com90193476
 /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
 "msg": "User was BackEnd"
 }
 
  TASK [debug] 
 
 ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
 /was//testingjsp   FrontEnd) => {
 "msg": "Hello world!"
 }
 ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
 2019-09-13 15:38 /fin/com/testingcom.com90193476
 /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
 "msg": "Hello world!"
 }
  
>>> 
 TASK [debug] 
 
 ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
 /was//testingjsp   FrontEnd) => {
 "msg": "'user2'"
 }
 ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
 2019-09-13 15:38 /fin/com/testingcom.com90193476
 /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
 "msg": "'user2'"
 }
>>> 
 On Wednesday, September 25, 2019 at 3:30:19 PM UTC+5:30, Stefan Hornburg 
 (Racke) wrote:
 On 9/25/19 11:13 AM, Mohtashim S wrote: 
 > @Stefan. The information provided by me is complete.  
 > 
 > The variable if not assigned a value defaults 

[ansible-project] Ansible's plans regarding Python 2 EOL

2019-09-25 Thread Andrew Feller
We've all seen the warnings about Python 2 support ceasing on January 1st, 
2020 from various projects  including pip 
 
for 
months now.  I hoped Ansible blog 
 
would have officially and proactively addressed the topic as this may 
require significant work for Ansible customers and the Ansible project over 
and above the early, minimal Python 3 support documentation 

 including 
Ansible package distribution requiring python 2.x and potential migration 
guides for various Linux distributions if not Red Hat family at the least; past 
threads 

 
highlight tradeoffs over package versus pip installation.

Does anyone have more information than what is cited above?

-- 
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/3fd978ce-4f51-42ef-abed-c25504a9926f%40googlegroups.com.


Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
Yes, If you look at my original post the very first post the same array 
item.split('\t')[3] very much prints FrontEnd and BackEnd text.

On Wednesday, September 25, 2019 at 5:50:34 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 2:15 PM, Mohtashim S wrote: 
> > I did this but for some reason is is not getting user1 ... it is still 
> getting user2 as the value.  
> > 
> > | 
> >-set_fact: 
> >USER: "user1" 
> >  when:item.split('\t')[3]=="FrontEnd" 
> >  with_items:"{{ command_result.stdout_lines }}" 
> > 
> > 
> >-set_fact: 
> >USER: "user2" 
> >  when:item.split('\t')[3]=="BackEnd" 
> > 
> > 
> >  with_items:"{{ command_result.stdout_lines }}" 
> > 
> > 
> >-debug: 
> >msg:"User has {{ USER }}" 
> >  with_items:"{{ command_result.stdout_lines }}" 
> > 
>
> Did you take in account that the array index starts with zero, so 
> item.split('\t')[3] addresses the fourth column in 
> your output? 
>
> Regards 
>   Racke 
>
> > | 
> > 
> > 
> > Output: 
> > 
> > 
> > TASK [debug] 
> > 
> 
>  
>
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 
> > /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> > "msg": "User has user2" 
> > } 
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 
> > 367595418\n-rw-rw-r-- user2 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
> > /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 
> 15:38 /fin/com/testingcom.com 90193476
> > /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => { 
> > "msg": "User has user2" 
> > } 
> > 
> > 
> > 
> > 
> > On Wednesday, September 25, 2019 at 5:23:07 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 9/25/19 1:46 PM, Mohtashim S wrote: 
> > > @ej does not help ! 
> > > 
> > > | 
> > >-debug: 
> > >  var: 
> > > USER:"{% if item.split('\t')[3] == 'FrontEnd' %}user1{% 
> else %}'user2'{% endif %}" with_items:"{{ 
> > > command_result.stdout_lines }}" 
> > > | 
> > > 
> > 
> > It's better to split this into two tasks, IMHO debug should just 
> output the message. 
> > 
> > - set_fact: 
> > USER:  
> >with_items: ... 
> > 
> > - debug: 
> > msg: "{{ USER }}" 
> > 
> > Regards 
> >  Racke 
> > 
> > > 
> > > | 
> > > ERROR!'var'isnota valid attribute fora Task 
> > > 
> > > 
> > > Theerror appears to be 
> in'/app/axmw/Ansible/playbook/finacle_deployment/testinclude.yml.bkp':line 
> 24,column 6,but may 
> > > be elsewhere inthe file depending on the exact syntax problem. 
> > > 
> > > 
> > > Theoffending line appears to be: 
> > > 
> > > 
> > > 
> > > 
> > >-debug: 
> > >  ^here 
> > > 
> > > | 
> > > 
> > > 
> > > 
> > > On Wednesday, September 25, 2019 at 4:59:45 PM UTC+5:30, ej wrote: 
> > > 
> > > Hello Mohtashim, 
> > > In your debug statement, try “var” instead of “vars”.  
> > > 
> > > On Sep 25, 2019, at 5:13 AM, Mohtashim S  > wrote: 
> > > 
> > >> There are two issues that i see.  
> > >> 
> > >> 1. I do not know how-to assign a variable USER value based on 
> condition in the loop  
> > >> 
> > >> Thus, instead of printing  msg: "{% if 
> item.split('\t')[3] == 'FrontEnd' %}user1{% else %}'user2'{% 
> > endif 
> > >> %}"  i wish to print "{{ USER }}" 
> > >> 
> > >> 2.  
> > >> 
> > >>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% 
> else %}'user2'{% endif %}"  always prints user2. I 
> > >> guess it is not able to match FrontEnd. 
> > >> 
> > >> The issue could be with the if else statement or 
> item.split('\t')[3] may have some space due to which the match 
> > >> fails.  
> > >> 
> > >> Below is the current output for this playbook: 
> > >> 
> > >> |   - debug: 
> > >>msg: "User was {{ item.split('\t')[3] }}" 
> > >>  with_items: "{{ command_result.stdout_lines }}" 
> > >> 
> > >> 
> > >>- debug: 
> > >>  vars: 
> > >>USER: "{% if item.split('\t')[3] == 'FrontEnd' 
> %}user1{% else %}'user2'{% endif %}" 
> > >>msg: "User is {{ USER }}" 
> > >>  with_items: "{{ command_result.stdout_lines }}" 
> > >> 
> > >>- debug: 
> > >> | 
> > >> | 
> > >>msg:"{% if item.split('\t')[3] == 'FrontEnd' %}user1{% 
> else 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Stefan Hornburg (Racke)
On 9/25/19 2:15 PM, Mohtashim S wrote:
> I did this but for some reason is is not getting user1 ... it is still 
> getting user2 as the value. 
> 
> |
>    -set_fact:
>        USER: "user1"
>      when:item.split('\t')[3]=="FrontEnd"
>      with_items:"{{ command_result.stdout_lines }}"
> 
> 
>    -set_fact:
>        USER: "user2"
>      when:item.split('\t')[3]=="BackEnd"
> 
> 
>      with_items:"{{ command_result.stdout_lines }}"
> 
> 
>    -debug:
>        msg:"User has {{ USER }}"
>      with_items:"{{ command_result.stdout_lines }}"
> 

Did you take in account that the array index starts with zero, so 
item.split('\t')[3] addresses the fourth column in
your output?

Regards
  Racke

> |
> 
> 
> Output:
> 
> 
> TASK [debug]
> 
> 
> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39
> /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp   FrontEnd) 
> => {
>     "msg": "User has user2"
> }
> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr
> 367595418\n-rw-rw-r-- user2 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37
> /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 15:38 
> /fin/com/testingcom.com 90193476       
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>     "msg": "User has user2"
> }
> 
> 
> 
> 
> On Wednesday, September 25, 2019 at 5:23:07 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote:
> 
> On 9/25/19 1:46 PM, Mohtashim S wrote:
> > @ej does not help !
> >
> > |
> >    -debug:
> >      var:
> >         USER:"{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"     with_items:"{{
> > command_result.stdout_lines }}"
> > |
> >
> 
> It's better to split this into two tasks, IMHO debug should just output 
> the message.
> 
> - set_fact:
>     USER: 
>    with_items: ...
> 
> - debug:
>     msg: "{{ USER }}"
> 
> Regards
>          Racke
> 
> >
> > |
> > ERROR!'var'isnota valid attribute fora Task
> >
> >
> > Theerror appears to be 
> in'/app/axmw/Ansible/playbook/finacle_deployment/testinclude.yml.bkp':line 
> 24,column 6,but may
> > be elsewhere inthe file depending on the exact syntax problem.
> >
> >
> > Theoffending line appears to be:
> >
> >
> >
> >
> >    -debug:
> >      ^here
> >
> > |
> >
> >
> >
> > On Wednesday, September 25, 2019 at 4:59:45 PM UTC+5:30, ej wrote:
> >
> >     Hello Mohtashim,
> >     In your debug statement, try “var” instead of “vars”. 
> >
> >     On Sep 25, 2019, at 5:13 AM, Mohtashim S  > wrote:
> >
> >>     There are two issues that i see. 
> >>
> >>     1. I do not know how-to assign a variable USER value based on 
> condition in the loop 
> >>
> >>     Thus, instead of printing          msg: "{% if item.split('\t')[3] 
> == 'FrontEnd' %}user1{% else %}'user2'{%
> endif
> >>     %}"  i wish to print "{{ USER }}"
> >>
> >>     2. 
> >>
> >>           msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"  always prints user2. I
> >>     guess it is not able to match FrontEnd.
> >>
> >>     The issue could be with the if else statement or 
> item.split('\t')[3] may have some space due to which the match
> >>     fails. 
> >>
> >>     Below is the current output for this playbook:
> >>
> >>     |   - debug:
> >>            msg: "User was {{ item.split('\t')[3] }}"
> >>          with_items: "{{ command_result.stdout_lines }}"
> >>
> >>
> >>        - debug:
> >>          vars:
> >>            USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% 
> else %}'user2'{% endif %}"
> >>            msg: "User is {{ USER }}"
> >>          with_items: "{{ command_result.stdout_lines }}"
> >>
> >>        - debug:
> >>     |
> >>     |
> >>            msg:"{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"
> >>          with_items:"{{ command_result.stdout_lines }}"
> >>     |
> >>
> >>
> >>
> >>     Output:
> >>
> >>         TASK [debug]
> >>        
> 
> 
> 
> >>         ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- 
> user1 2019-09-13 15:39
> >>         /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp   
> FrontEnd) => {
> >>             "msg": "User was FrontEnd"
> >>    

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
I did this but for some reason is is not getting user1 ... it is still 
getting user2 as the value. 

   - set_fact:
   USER:  "user1"
 when: item.split('\t')[3] == "FrontEnd"
 with_items: "{{ command_result.stdout_lines }}"


   - set_fact:
   USER:  "user2"
 when: item.split('\t')[3] == "BackEnd"


 with_items: "{{ command_result.stdout_lines }}"


   - debug:
   msg: "User has {{ USER }}"
 with_items: "{{ command_result.stdout_lines }}"



Output:


TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "User has user2"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com 90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "User has user2"
> }




On Wednesday, September 25, 2019 at 5:23:07 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 1:46 PM, Mohtashim S wrote: 
> > @ej does not help ! 
> > 
> > | 
> >-debug: 
> >  var: 
> > USER:"{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}" with_items:"{{ 
> > command_result.stdout_lines }}" 
> > | 
> > 
>
> It's better to split this into two tasks, IMHO debug should just output 
> the message. 
>
> - set_fact: 
> USER:  
>with_items: ... 
>
> - debug: 
> msg: "{{ USER }}" 
>
> Regards 
>  Racke 
>
> > 
> > | 
> > ERROR!'var'isnota valid attribute fora Task 
> > 
> > 
> > Theerror appears to be 
> in'/app/axmw/Ansible/playbook/finacle_deployment/testinclude.yml.bkp':line 
> 24,column 6,but may 
> > be elsewhere inthe file depending on the exact syntax problem. 
> > 
> > 
> > Theoffending line appears to be: 
> > 
> > 
> > 
> > 
> >-debug: 
> >  ^here 
> > 
> > | 
> > 
> > 
> > 
> > On Wednesday, September 25, 2019 at 4:59:45 PM UTC+5:30, ej wrote: 
> > 
> > Hello Mohtashim, 
> > In your debug statement, try “var” instead of “vars”.  
> > 
> > On Sep 25, 2019, at 5:13 AM, Mohtashim S  > wrote: 
> > 
> >> There are two issues that i see.  
> >> 
> >> 1. I do not know how-to assign a variable USER value based on 
> condition in the loop  
> >> 
> >> Thus, instead of printing  msg: "{% if item.split('\t')[3] 
> == 'FrontEnd' %}user1{% else %}'user2'{% endif 
> >> %}"  i wish to print "{{ USER }}" 
> >> 
> >> 2.  
> >> 
> >>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"  always prints user2. I 
> >> guess it is not able to match FrontEnd. 
> >> 
> >> The issue could be with the if else statement or 
> item.split('\t')[3] may have some space due to which the match 
> >> fails.  
> >> 
> >> Below is the current output for this playbook: 
> >> 
> >> |   - debug: 
> >>msg: "User was {{ item.split('\t')[3] }}" 
> >>  with_items: "{{ command_result.stdout_lines }}" 
> >> 
> >> 
> >>- debug: 
> >>  vars: 
> >>USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% 
> else %}'user2'{% endif %}" 
> >>msg: "User is {{ USER }}" 
> >>  with_items: "{{ command_result.stdout_lines }}" 
> >> 
> >>- debug: 
> >> | 
> >> | 
> >>msg:"{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}" 
> >>  with_items:"{{ command_result.stdout_lines }}" 
> >> | 
> >> 
> >> 
> >> 
> >> Output: 
> >> 
> >> TASK [debug] 
> >> 
> 
>  
>
> >> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- 
> user1 2019-09-13 15:39 
> >> /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> >> "msg": "User was FrontEnd" 
> >> } 
> >> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- 
> user2 2019-09-13 15:29 
> >> /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> >> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
> /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 
> >> 15:38 /fin/com/testingcom.com 90193476  
>   
> >> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => { 
> >> "msg": "User was BackEnd" 
> >> } 
> >> 
> >> 
> >>  

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Stefan Hornburg (Racke)
On 9/25/19 1:46 PM, Mohtashim S wrote:
> @ej does not help !
> 
> |
>    -debug:
>      var:
>         USER:"{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"     with_items:"{{
> command_result.stdout_lines }}"
> |
> 

It's better to split this into two tasks, IMHO debug should just output the 
message.

- set_fact:
USER: 
   with_items: ...

- debug:
msg: "{{ USER }}"

Regards
 Racke

> 
> |
> ERROR!'var'isnota valid attribute fora Task
> 
> 
> Theerror appears to be 
> in'/app/axmw/Ansible/playbook/finacle_deployment/testinclude.yml.bkp':line 
> 24,column 6,but may
> be elsewhere inthe file depending on the exact syntax problem.
> 
> 
> Theoffending line appears to be:
> 
> 
> 
> 
>    -debug:
>      ^here
> 
> |
> 
> 
> 
> On Wednesday, September 25, 2019 at 4:59:45 PM UTC+5:30, ej wrote:
> 
> Hello Mohtashim,
> In your debug statement, try “var” instead of “vars”. 
> 
> On Sep 25, 2019, at 5:13 AM, Mohtashim S  > wrote:
> 
>> There are two issues that i see. 
>>
>> 1. I do not know how-to assign a variable USER value based on condition 
>> in the loop 
>>
>> Thus, instead of printing          msg: "{% if item.split('\t')[3] == 
>> 'FrontEnd' %}user1{% else %}'user2'{% endif
>> %}"  i wish to print "{{ USER }}"
>>
>> 2. 
>>
>>       msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
>> %}'user2'{% endif %}"  always prints user2. I
>> guess it is not able to match FrontEnd.
>>
>> The issue could be with the if else statement or item.split('\t')[3] may 
>> have some space due to which the match
>> fails. 
>>
>> Below is the current output for this playbook:
>>
>> |   - debug:
>>        msg: "User was {{ item.split('\t')[3] }}"
>>      with_items: "{{ command_result.stdout_lines }}"
>>
>>
>>    - debug:
>>      vars:
>>        USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
>> %}'user2'{% endif %}"
>>        msg: "User is {{ USER }}"
>>      with_items: "{{ command_result.stdout_lines }}"
>>
>>    - debug:
>> |
>> |
>>        msg:"{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
>> %}'user2'{% endif %}"
>>      with_items:"{{ command_result.stdout_lines }}"
>> |
>>
>>
>>
>> Output:
>>
>> TASK [debug]
>> 
>> 
>> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39
>> /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp   
>> FrontEnd) => {
>>     "msg": "User was FrontEnd"
>> }
>> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29
>> /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 2019-09-13 
>> 15:36 /fin/mrt/testingmrt.mrt
>> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
>> /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13
>> 15:38 /fin/com/testingcom.com 90193476       
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>>     "msg": "User was BackEnd"
>> }
>>
>>
>>  TASK [debug]
>> 
>> 
>> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39
>> /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp   
>> FrontEnd) => {
>>     "msg": "Hello world!"
>> }
>> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29
>> /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 2019-09-13 
>> 15:36 /fin/mrt/testingmrt.mrt
>> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
>> /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13
>> 15:38 /fin/com/testingcom.com 90193476       
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>>     "msg": "Hello world!"
>> }
>>
>>  
>>
>> TASK [debug]
>> 
>> 
>> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39
>> /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp   
>> FrontEnd) => {
>>     "msg": "'user2'"
>> }
>> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29
>> /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 2019-09-13 
>> 15:36 /fin/mrt/testingmrt.mrt
>> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
>> 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
@ej does not help !

   - debug:
 var:
USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"
 with_items: "{{ command_result.stdout_lines }}"


ERROR! 'var' is not a valid attribute for a Task
The error appears to be in '/app/testinclude.yml.bkp': line 24, column 6, but 
may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

   - debug:
 ^ here

On Wednesday, September 25, 2019 at 4:59:45 PM UTC+5:30, ej wrote:
>
> Hello Mohtashim,
> In your debug statement, try “var” instead of “vars”. 
>
> On Sep 25, 2019, at 5:13 AM, Mohtashim S > 
> wrote:
>
> There are two issues that i see. 
>
> 1. I do not know how-to assign a variable USER value based on condition in 
> the loop 
>
> Thus, instead of printing  msg: "{% if item.split('\t')[3] == 
> 'FrontEnd' %}user1{% else %}'user2'{% endif %}"  i wish to print "{{ USER 
> }}"
>
> 2. 
>
>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"  always prints user2. I guess it is not able to match 
> FrontEnd.
>
> The issue could be with the if else statement or item.split('\t')[3] may 
> have some space due to which the match fails. 
>
> Below is the current output for this playbook:
>
>- debug:
>msg: "User was {{ item.split('\t')[3] }}"
>  with_items: "{{ command_result.stdout_lines }}"
>
>
>- debug:
>  vars:
>USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"
>msg: "User is {{ USER }}"
>  with_items: "{{ command_result.stdout_lines }}"
>
>- debug:
>msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"
>  with_items: "{{ command_result.stdout_lines }}"
>
>
>
> Output:
>
> TASK [debug] 
>> 
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
>> /was//testingjsp   FrontEnd) => {
>> "msg": "User was FrontEnd"
>> }
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
>> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
>> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
>> 2019-09-13 15:38 /fin/com/testingcom.com90193476
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>> "msg": "User was BackEnd"
>> }
>>
>
>>  TASK [debug] 
>> 
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
>> /was//testingjsp   FrontEnd) => {
>> "msg": "Hello world!"
>> }
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
>> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
>> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
>> 2019-09-13 15:38 /fin/com/testingcom.com90193476
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>> "msg": "Hello world!"
>> }
>
>  
>
> TASK [debug] 
>> 
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
>> /was//testingjsp   FrontEnd) => {
>> "msg": "'user2'"
>> }
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
>> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
>> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
>> 2019-09-13 15:38 /fin/com/testingcom.com90193476
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>> "msg": "'user2'"
>> }
>
>
> On Wednesday, September 25, 2019 at 3:30:19 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote:
>>
>> On 9/25/19 11:13 AM, Mohtashim S wrote: 
>> > @Stefan. The information provided by me is complete.  
>> > 
>> > The variable if not assigned a value defaults as "Hello World" 
>> > 
>> > Reference: 
>> https://docs.ansible.com/ansible/latest/modules/debug_module.html 
>> > 
>>
>> Ha - I never ran in that one. Alas, you need to resort to proper if else 
>> statements in order to get your 
>> logic to work: 
>>
>>   - debug: 
>>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
>> %}'user2'{% endif %}" 
>> with_items: "{{ command_result.stdout_lines }}" 
>>
>> 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
@ej does not help !

   - debug:
 var:
USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"  with_items: "{{ command_result.stdout_lines }}" 


ERROR! 'var' is not a valid attribute for a Task


The error appears to be in 
'/app/axmw/Ansible/playbook/finacle_deployment/testinclude.yml.bkp': line 24
, column 6, but may
be elsewhere in the file depending on the exact syntax problem.


The offending line appears to be:




   - debug:
 ^ here




On Wednesday, September 25, 2019 at 4:59:45 PM UTC+5:30, ej wrote:
>
> Hello Mohtashim,
> In your debug statement, try “var” instead of “vars”. 
>
> On Sep 25, 2019, at 5:13 AM, Mohtashim S > 
> wrote:
>
> There are two issues that i see. 
>
> 1. I do not know how-to assign a variable USER value based on condition in 
> the loop 
>
> Thus, instead of printing  msg: "{% if item.split('\t')[3] == 
> 'FrontEnd' %}user1{% else %}'user2'{% endif %}"  i wish to print "{{ USER 
> }}"
>
> 2. 
>
>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"  always prints user2. I guess it is not able to match 
> FrontEnd.
>
> The issue could be with the if else statement or item.split('\t')[3] may 
> have some space due to which the match fails. 
>
> Below is the current output for this playbook:
>
>- debug:
>msg: "User was {{ item.split('\t')[3] }}"
>  with_items: "{{ command_result.stdout_lines }}"
>
>
>- debug:
>  vars:
>USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"
>msg: "User is {{ USER }}"
>  with_items: "{{ command_result.stdout_lines }}"
>
>- debug:
>msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"
>  with_items: "{{ command_result.stdout_lines }}"
>
>
>
> Output:
>
> TASK [debug] 
>> 
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
>> /was//testingjsp   FrontEnd) => {
>> "msg": "User was FrontEnd"
>> }
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
>> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
>> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
>> 2019-09-13 15:38 /fin/com/testingcom.com90193476
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>> "msg": "User was BackEnd"
>> }
>>
>
>>  TASK [debug] 
>> 
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
>> /was//testingjsp   FrontEnd) => {
>> "msg": "Hello world!"
>> }
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
>> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
>> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
>> 2019-09-13 15:38 /fin/com/testingcom.com90193476
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>> "msg": "Hello world!"
>> }
>
>  
>
> TASK [debug] 
>> 
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
>> /was//testingjsp   FrontEnd) => {
>> "msg": "'user2'"
>> }
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
>> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
>> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
>> 2019-09-13 15:38 /fin/com/testingcom.com90193476
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>> "msg": "'user2'"
>> }
>
>
> On Wednesday, September 25, 2019 at 3:30:19 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote:
>>
>> On 9/25/19 11:13 AM, Mohtashim S wrote: 
>> > @Stefan. The information provided by me is complete.  
>> > 
>> > The variable if not assigned a value defaults as "Hello World" 
>> > 
>> > Reference: 
>> https://docs.ansible.com/ansible/latest/modules/debug_module.html 
>> > 
>>
>> Ha - I never ran in that one. Alas, you need to resort to proper if else 
>> statements in order to get your 
>> logic to work: 
>>
>>   - debug: 
>>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
>> %}'user2'{% endif %}" 
>> 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Eric Jolley
Hello Mohtashim,
In your debug statement, try “var” instead of “vars”. 

> On Sep 25, 2019, at 5:13 AM, Mohtashim S  wrote:
> 
> There are two issues that i see. 
> 
> 1. I do not know how-to assign a variable USER value based on condition in 
> the loop 
> 
> Thus, instead of printing  msg: "{% if item.split('\t')[3] == 
> 'FrontEnd' %}user1{% else %}'user2'{% endif %}"  i wish to print "{{ USER }}"
> 
> 2. 
> 
>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"  always prints user2. I guess it is not able to match 
> FrontEnd.
> 
> The issue could be with the if else statement or item.split('\t')[3] may have 
> some space due to which the match fails. 
> 
> Below is the current output for this playbook:
> 
>- debug:
>msg: "User was {{ item.split('\t')[3] }}"
>  with_items: "{{ command_result.stdout_lines }}"
> 
> 
>- debug:
>  vars:
>USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"
>msg: "User is {{ USER }}"
>  with_items: "{{ command_result.stdout_lines }}"
> 
>- debug:
>msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}"
>  with_items: "{{ command_result.stdout_lines }}"
> 
> 
> 
> Output:
> 
>> TASK [debug] 
>> 
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
>> /was//testingjsp   FrontEnd) => {
>> "msg": "User was FrontEnd"
>> }
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
>> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
>> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
>> 2019-09-13 15:38 /fin/com/testingcom.com90193476
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>> "msg": "User was BackEnd"
>> }
>> 
>>  TASK [debug] 
>> 
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
>> /was//testingjsp   FrontEnd) => {
>> "msg": "Hello world!"
>> }
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
>> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
>> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
>> 2019-09-13 15:38 /fin/com/testingcom.com90193476
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>> "msg": "Hello world!"
>> }
>>  
> 
>> TASK [debug] 
>> 
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
>> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
>> /was//testingjsp   FrontEnd) => {
>> "msg": "'user2'"
>> }
>> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
>> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
>> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
>> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
>> 2019-09-13 15:38 /fin/com/testingcom.com90193476
>> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>> "msg": "'user2'"
>> }
> 
>> On Wednesday, September 25, 2019 at 3:30:19 PM UTC+5:30, Stefan Hornburg 
>> (Racke) wrote:
>> On 9/25/19 11:13 AM, Mohtashim S wrote: 
>> > @Stefan. The information provided by me is complete.  
>> > 
>> > The variable if not assigned a value defaults as "Hello World" 
>> > 
>> > Reference: 
>> > https://docs.ansible.com/ansible/latest/modules/debug_module.html 
>> > 
>> 
>> Ha - I never ran in that one. Alas, you need to resort to proper if else 
>> statements in order to get your 
>> logic to work: 
>> 
>>   - debug: 
>>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
>> %}'user2'{% endif %}" 
>> with_items: "{{ command_result.stdout_lines }}" 
>> 
>> Regards 
>>  Racke 
>> 
>> > You can recreate the playbook output. 
>> > 
>> > On Wednesday, September 25, 2019 at 2:23:22 PM UTC+5:30, Stefan Hornburg 
>> > (Racke) wrote: 
>> > 
>> > On 9/25/19 10:44 AM, Mohtashim S wrote: 
>> > > @Stefan here is the output 
>> > > 
>> > 
>> > Sorry but there is no "Hello world" in the tasks you posted. Providing 
>> > inaccurate information isn't helpful. 
>> > 
>> > Regards 
>> >  Racke 
>> > 
>> > 
>> > > TASK [debug] 
>> 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
There are two issues that i see. 

1. I do not know how-to assign a variable USER value based on condition in 
the loop 

Thus, instead of printing  msg: "{% if item.split('\t')[3] == 
'FrontEnd' %}user1{% else %}'user2'{% endif %}"  i wish to print "{{ USER 
}}"

2. 

  msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"  always prints user2. I guess it is not able to match 
FrontEnd.

The issue could be with the if else statement or item.split('\t')[3] may 
have some space due to which the match fails. 

Below is the current output for this playbook:

   - debug:
   msg: "User was {{ item.split('\t')[3] }}"
 with_items: "{{ command_result.stdout_lines }}"


   - debug:
 vars:
   USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"
   msg: "User is {{ USER }}"
 with_items: "{{ command_result.stdout_lines }}"

   - debug:
   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"
 with_items: "{{ command_result.stdout_lines }}"



Output:

TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "User was FrontEnd"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "User was BackEnd"
> }
>

>  TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "Hello world!"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "Hello world!"
> }

 

TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "'user2'"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "'user2'"
> }


On Wednesday, September 25, 2019 at 3:30:19 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 11:13 AM, Mohtashim S wrote: 
> > @Stefan. The information provided by me is complete.  
> > 
> > The variable if not assigned a value defaults as "Hello World" 
> > 
> > Reference: 
> https://docs.ansible.com/ansible/latest/modules/debug_module.html 
> > 
>
> Ha - I never ran in that one. Alas, you need to resort to proper if else 
> statements in order to get your 
> logic to work: 
>
>   - debug: 
>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}" 
> with_items: "{{ command_result.stdout_lines }}" 
>
> Regards 
>  Racke 
>
> > You can recreate the playbook output. 
> > 
> > On Wednesday, September 25, 2019 at 2:23:22 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 9/25/19 10:44 AM, Mohtashim S wrote: 
> > > @Stefan here is the output 
> > > 
> > 
> > Sorry but there is no "Hello world" in the tasks you posted. 
> Providing inaccurate information isn't helpful. 
> > 
> > Regards 
> >  Racke 
> > 
> > 
> > > TASK [debug] 
> > > 
> > 
> 
>  
>
> > 
> > > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- 
> user1 2019-09-13 15:39 
> > > 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
There are two issues that i see. 

1. I do not know how-to assign a variable USER value based on condition in 
the loop 

Thus, instead of printing  msg: "{% if item.split('\t')[3] == 
'FrontEnd' %}user1{% else %}'user2'{% endif %}"  i wish to print "{{ USER 
}}"

2. 

  msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"  always prints user2. I guess it is not able to match 
FrontEnd.

The issue could be with the if else statement or item.split('\t')[3] may 
have some space due to which the match fails. 

Below is the current output for this playbook:

   - debug:
   msg: "User was {{ item.split('\t')[3] }}"
 with_items: "{{ command_result.stdout_lines }}"


   - debug:
 vars:
USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"
 msg: "User is {{ USER }}"


   - debug:
   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"


Output:

TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "User was FrontEnd"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "User was BackEnd"
> }
>

>  TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "Hello world!"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "Hello world!"
> }

 

TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "'user2'"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "'user2'"
> }
>
>
On Wednesday, September 25, 2019 at 3:30:19 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 11:13 AM, Mohtashim S wrote: 
> > @Stefan. The information provided by me is complete.  
> > 
> > The variable if not assigned a value defaults as "Hello World" 
> > 
> > Reference: 
> https://docs.ansible.com/ansible/latest/modules/debug_module.html 
> > 
>
> Ha - I never ran in that one. Alas, you need to resort to proper if else 
> statements in order to get your 
> logic to work: 
>
>   - debug: 
>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}" 
> with_items: "{{ command_result.stdout_lines }}" 
>
> Regards 
>  Racke 
>
> > You can recreate the playbook output. 
> > 
> > On Wednesday, September 25, 2019 at 2:23:22 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 9/25/19 10:44 AM, Mohtashim S wrote: 
> > > @Stefan here is the output 
> > > 
> > 
> > Sorry but there is no "Hello world" in the tasks you posted. 
> Providing inaccurate information isn't helpful. 
> > 
> > Regards 
> >  Racke 
> > 
> > 
> > > TASK [debug] 
> > > 
> > 
> 
>  
>
> > 
> > > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- 
> user1 2019-09-13 15:39 
> > > /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> > > "msg": "User was 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
There are two issues that i see. 

1. I do not know how-to assign a variable USER value based on condition in 
the loop 

Thus, instead of printing  msg: "{% if item.split('\t')[3] == 
'FrontEnd' %}user1{% else %}'user2'{% endif %}"  i wish to print "{{ USER 
}}"

2. 

  msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"  always prints user2. I guess it is not able to match 
FrontEnd.

The issue could be with the if else statement or item.split('\t')[3] may 
have some space due to which the match fails. 

Below is the current output for this playbook:

   - debug:
   msg: "User was {{ item.split('\t')[3] }}"
 with_items: "{{ command_result.stdout_lines }}"


   - debug:
 vars:
USER: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"
 msg: "User is {{ USER }}"


   - debug:
   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"


Output:

TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "User was FrontEnd"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "User was BackEnd"
> }
> TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "'user2'"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "'user2'"
> }
> TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "Hello world!"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "Hello world!"
> }


On Wednesday, September 25, 2019 at 3:30:19 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 11:13 AM, Mohtashim S wrote: 
> > @Stefan. The information provided by me is complete.  
> > 
> > The variable if not assigned a value defaults as "Hello World" 
> > 
> > Reference: 
> https://docs.ansible.com/ansible/latest/modules/debug_module.html 
> > 
>
> Ha - I never ran in that one. Alas, you need to resort to proper if else 
> statements in order to get your 
> logic to work: 
>
>   - debug: 
>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}" 
> with_items: "{{ command_result.stdout_lines }}" 
>
> Regards 
>  Racke 
>
> > You can recreate the playbook output. 
> > 
> > On Wednesday, September 25, 2019 at 2:23:22 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 9/25/19 10:44 AM, Mohtashim S wrote: 
> > > @Stefan here is the output 
> > > 
> > 
> > Sorry but there is no "Hello world" in the tasks you posted. 
> Providing inaccurate information isn't helpful. 
> > 
> > Regards 
> >  Racke 
> > 
> > 
> > > TASK [debug] 
> > > 
> > 
> 
>  
>
> > 
> > > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- 
> user1 2019-09-13 15:39 
> > > /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> > > "msg": "User was FrontEnd" 
> 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
There are two issues that i see. 

1. I do not know how-to assign a variable USER value based on condition in 
the loop 

Thus, instead of printing  msg: "{% if item.split('\t')[3] == 
'FrontEnd' %}user1{% else %}'user2'{% endif %}"  i wish to print "{{ USER 
}}"

2. 

  msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
%}'user2'{% endif %}"  always prints user2. I guess it is not able to match 
FrontEnd.

The issue could be with the if else statement or item.split('\t')[3] may 
have some space due to which the match fails. 

Below is the current output for this playbook:

   - debug:
   msg: "User was {{ item.split('\t')[3] }}"
 with_items: "{{ command_result.stdout_lines }}"


   - debug:
 vars:
USER: "{% if item.split('\t')[3] == 'FrontEnd_WEB' %}user1{% else 
%}'user2'{% endif %}"
 msg: "User is {{ USER }}"


   - debug:
   msg: "{% if item.split('\t')[3] == 'FrontEnd_WEB' %}user1{% else 
%}'user2'{% endif %}"


Output:

TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "User was FrontEnd"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com 90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "User was BackEnd"
> }
> TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "'user2'"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com 90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "'user2'"
> }
> TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "Hello world!"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com 90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "Hello world!"
> }
>



On Wednesday, September 25, 2019 at 3:30:19 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 11:13 AM, Mohtashim S wrote: 
> > @Stefan. The information provided by me is complete.  
> > 
> > The variable if not assigned a value defaults as "Hello World" 
> > 
> > Reference: 
> https://docs.ansible.com/ansible/latest/modules/debug_module.html 
> > 
>
> Ha - I never ran in that one. Alas, you need to resort to proper if else 
> statements in order to get your 
> logic to work: 
>
>   - debug: 
>   msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else 
> %}'user2'{% endif %}" 
> with_items: "{{ command_result.stdout_lines }}" 
>
> Regards 
>  Racke 
>
> > You can recreate the playbook output. 
> > 
> > On Wednesday, September 25, 2019 at 2:23:22 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 9/25/19 10:44 AM, Mohtashim S wrote: 
> > > @Stefan here is the output 
> > > 
> > 
> > Sorry but there is no "Hello world" in the tasks you posted. 
> Providing inaccurate information isn't helpful. 
> > 
> > Regards 
> >  Racke 
> > 
> > 
> > > TASK [debug] 
> > > 
> > 
> 
>  
>
> > 
> > > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- 
> user1 2019-09-13 15:39 
> > > /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> > > "msg": "User 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Stefan Hornburg (Racke)
On 9/25/19 11:13 AM, Mohtashim S wrote:
> @Stefan. The information provided by me is complete. 
> 
> The variable if not assigned a value defaults as "Hello World"
> 
> Reference: https://docs.ansible.com/ansible/latest/modules/debug_module.html
> 

Ha - I never ran in that one. Alas, you need to resort to proper if else 
statements in order to get your
logic to work:

  - debug:
  msg: "{% if item.split('\t')[3] == 'FrontEnd' %}user1{% else %}'user2'{% 
endif %}"
with_items: "{{ command_result.stdout_lines }}"

Regards
 Racke

> You can recreate the playbook output.
> 
> On Wednesday, September 25, 2019 at 2:23:22 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote:
> 
> On 9/25/19 10:44 AM, Mohtashim S wrote:
> > @Stefan here is the output
> >
> 
> Sorry but there is no "Hello world" in the tasks you posted. Providing 
> inaccurate information isn't helpful.
> 
> Regards
>          Racke
> 
> 
> >     TASK [debug]
> >    
> 
> 
> 
> >     ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- 
> user1 2019-09-13 15:39
> >     /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp   
> FrontEnd) => {
> >         "msg": "User was FrontEnd"
> >     }
> >     ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- 
> user2 2019-09-13 15:29 /fin/scripts/testingscr.scr
> >     367595418\n-rw-rw-r-- user2 2019-09-13 15:36 
> /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 2019-09-13
> 15:37
> >     /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 
> 15:38 /fin/com/testingcom.com
>  90193476       
> >     /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> >         "msg": "User was BackEnd"
> >     }
> >     TASK [debug]
> >    
> 
> 
> 
> >     ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- 
> user1 2019-09-13 15:39
> >     /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp   
> FrontEnd) => {
> >         "msg": "Hello world!"
> >     }
> >     ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- 
> user2 2019-09-13 15:29 /fin/scripts/testingscr.scr
> >     367595418\n-rw-rw-r-- user2 2019-09-13 15:36 
> /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 2019-09-13
> 15:37
> >     /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 
> 15:38 /fin/com/testingcom.com
>  90193476       
> >     /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> >         "msg": "Hello world!"
> >     }
> >
> >
> > On Wednesday, September 25, 2019 at 1:40:38 PM UTC+5:30, Stefan 
> Hornburg (Racke) wrote:
> >
> >     On 9/25/19 9:58 AM, Mohtashim S wrote:
> >     > |   - debug:
> >     >        msg: "User was {{ item.split('\t')[3] }}"
> >     >      with_items: "{{ command_result.stdout_lines }}"|
> >     >
> >     >
> >     > The above give me the below output:
> >     >
> >     >     "msg": "User was FrontEnd"
> >     >     "msg": "User was BackEnd"
> >     >
> >     >
> >     > I now wish to set USER variable as user1 is returned value is 
> FrontEnd else USER value should be user2.
> >     >
> >     > I dont know how to do this but below is my failing playbook. 
> >     >
> >     > |   - debug:
> >     >      vars:
> >     >         USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' 
> else 'user2' }}"
> >     >         msg: "User is {{ USER }}"
> >     >
> >     >      with_items: "{{ command_result.stdout_lines }}"|
> >     >
> >     >
> >     > Expected output is:
> >     >
> >     >     "msg": "User is user1"
> >     >     "msg": "User is user2"
> >     >
> >     >
> >     >
> >     > Can you please suggest ? 
> >     >
> >
> >     Hello,
> >
> >     what is the output that you actually get ... and please don't post 
> the same question twice.
> >
> >     Regards
> >              Racke
> >
> >     > --
> >     > 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/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com
> 
> 

Re: [ansible-project] Connection via Citrix

2019-09-25 Thread Srinivas Naram
Hello,

Can you please provide more details on how you are moving forward with the
setup ? Is any documentation available to understand how this can be
achieved ?

TIA

-- 
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/CAG-N3P4JcTz1_y%3D7_a2oi2MbDEKwzKMn%3Dog_BsJbLF9UTWH1_A%40mail.gmail.com.


Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
Here is my entire playbook:

---


- name: "Play 1"
  hosts: localhost
  gather_facts: no
  tasks:
   - name: "Search database"
 command: >   mysql --user=root --password=p@ssword deployment
   --host=localhost  -Ns -e "SELECT dest_ip,file_dets,install_dir,layer 
FROM deploy_dets"
 register: command_result




   - debug:
   msg: "User was {{ item.split('\t')[3] }}"
 with_items: "{{ command_result.stdout_lines }}"
  
   - debug:
 vars:
   USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' else 'user2' 
}}"
   msg: "User is {{ USER }}"
 with_items: "{{ command_result.stdout_lines }}" 


On Wednesday, September 25, 2019 at 1:40:38 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 9:58 AM, Mohtashim S wrote: 
> > |   - debug: 
> >msg: "User was {{ item.split('\t')[3] }}" 
> >  with_items: "{{ command_result.stdout_lines }}"| 
> > 
> > 
> > The above give me the below output: 
> > 
> > "msg": "User was FrontEnd" 
> > "msg": "User was BackEnd" 
> > 
> > 
> > I now wish to set USER variable as user1 is returned value is FrontEnd 
> else USER value should be user2. 
> > 
> > I dont know how to do this but below is my failing playbook.  
> > 
> > |   - debug: 
> >  vars: 
> > USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' else 
> 'user2' }}" 
> > msg: "User is {{ USER }}" 
> > 
> >  with_items: "{{ command_result.stdout_lines }}"| 
> > 
> > 
> > Expected output is: 
> > 
> > "msg": "User is user1" 
> > "msg": "User is user2" 
> > 
> > 
> > 
> > Can you please suggest ?  
> > 
>
> Hello, 
>
> what is the output that you actually get ... and please don't post the 
> same question twice. 
>
> Regards 
>  Racke 
>
> > -- 
> > 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/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/11286705-639c-43e2-8e0d-47080203cfc1%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/b669ded5-a252-44b9-b49a-000444a47b48%40googlegroups.com.


Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
Here is my entire playbook:

---

- name: "Play 1"
  hosts: localhost
  gather_facts: no
  tasks:
   - name: "Search database"
 command: >   mysql --user=root --password=p@ssword deployment
   --host=localhost  -Ns -e "SELECT dest_ip,file_dets,install_dir,layer 
FROM deploy_dets"
 register: command_result


   - debug:
   msg: "User was {{ item.split('\t')[3] }}"
 with_items: "{{ command_result.stdout_lines }}"
  
   - debug:
 vars:
   USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' else 'user2' 
}}"
   msg: "User is {{ USER }}"
 with_items: "{{ command_result.stdout_lines }}" 

On Wednesday, September 25, 2019 at 2:23:22 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 10:44 AM, Mohtashim S wrote: 
> > @Stefan here is the output 
> > 
>
> Sorry but there is no "Hello world" in the tasks you posted. Providing 
> inaccurate information isn't helpful. 
>
> Regards 
>  Racke 
>
>
> > TASK [debug] 
> > 
> 
>  
>
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 
> > /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> > "msg": "User was FrontEnd" 
> > } 
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 
> > 367595418\n-rw-rw-r-- user2 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
> > /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 
> 15:38 /fin/com/testingcom.com 90193476
> > /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => { 
> > "msg": "User was BackEnd" 
> > } 
> > TASK [debug] 
> > 
> 
>  
>
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 
> > /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> > "msg": "Hello world!" 
> > } 
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 
> > 367595418\n-rw-rw-r-- user2 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
> > /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 
> 15:38 /fin/com/testingcom.com 90193476
> > /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => { 
> > "msg": "Hello world!" 
> > } 
> > 
> > 
> > On Wednesday, September 25, 2019 at 1:40:38 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 9/25/19 9:58 AM, Mohtashim S wrote: 
> > > |   - debug: 
> > >msg: "User was {{ item.split('\t')[3] }}" 
> > >  with_items: "{{ command_result.stdout_lines }}"| 
> > > 
> > > 
> > > The above give me the below output: 
> > > 
> > > "msg": "User was FrontEnd" 
> > > "msg": "User was BackEnd" 
> > > 
> > > 
> > > I now wish to set USER variable as user1 is returned value is 
> FrontEnd else USER value should be user2. 
> > > 
> > > I dont know how to do this but below is my failing playbook.  
> > > 
> > > |   - debug: 
> > >  vars: 
> > > USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' 
> else 'user2' }}" 
> > > msg: "User is {{ USER }}" 
> > > 
> > >  with_items: "{{ command_result.stdout_lines }}"| 
> > > 
> > > 
> > > Expected output is: 
> > > 
> > > "msg": "User is user1" 
> > > "msg": "User is user2" 
> > > 
> > > 
> > > 
> > > Can you please suggest ?  
> > > 
> > 
> > Hello, 
> > 
> > what is the output that you actually get ... and please don't post 
> the same question twice. 
> > 
> > Regards 
> >  Racke 
> > 
> > > -- 
> > > 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/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com>
>  
>
> > > 
> > <
> https://groups.google.com/d/msgid/ansible-project/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com?utm_medium=email_source=footer
>  
> > <
> 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
Here is my entire playbook:

---

- name: "Play 1"
  hosts: localhost
  gather_facts: no
  tasks:
   - name: "Search database"
 command: >   mysql --user=root --password=p@ssword deployment
   --host=localhost  -Ns -e "SELECT dest_ip,file_dets,install_dir,layer 
FROM deploy_dets"
 register: command_result


   - debug:
   msg: "User was {{ item.split('\t')[3] }}"
 with_items: "{{ command_result.stdout_lines }}"
  
   - debug:
 vars:
   USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' else 'user2' 
}}"
   msg: "User is {{ USER }}"
 with_items: "{{ command_result.stdout_lines }}"  

 

On Wednesday, September 25, 2019 at 2:23:22 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 10:44 AM, Mohtashim S wrote: 
> > @Stefan here is the output 
> > 
>
> Sorry but there is no "Hello world" in the tasks you posted. Providing 
> inaccurate information isn't helpful. 
>
> Regards 
>  Racke 
>
>
> > TASK [debug] 
> > 
> 
>  
>
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 
> > /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> > "msg": "User was FrontEnd" 
> > } 
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 
> > 367595418\n-rw-rw-r-- user2 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
> > /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 
> 15:38 /fin/com/testingcom.com 90193476
> > /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => { 
> > "msg": "User was BackEnd" 
> > } 
> > TASK [debug] 
> > 
> 
>  
>
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 
> > /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> > "msg": "Hello world!" 
> > } 
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 
> > 367595418\n-rw-rw-r-- user2 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
> > /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 
> 15:38 /fin/com/testingcom.com 90193476
> > /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => { 
> > "msg": "Hello world!" 
> > } 
> > 
> > 
> > On Wednesday, September 25, 2019 at 1:40:38 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 9/25/19 9:58 AM, Mohtashim S wrote: 
> > > |   - debug: 
> > >msg: "User was {{ item.split('\t')[3] }}" 
> > >  with_items: "{{ command_result.stdout_lines }}"| 
> > > 
> > > 
> > > The above give me the below output: 
> > > 
> > > "msg": "User was FrontEnd" 
> > > "msg": "User was BackEnd" 
> > > 
> > > 
> > > I now wish to set USER variable as user1 is returned value is 
> FrontEnd else USER value should be user2. 
> > > 
> > > I dont know how to do this but below is my failing playbook.  
> > > 
> > > |   - debug: 
> > >  vars: 
> > > USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' 
> else 'user2' }}" 
> > > msg: "User is {{ USER }}" 
> > > 
> > >  with_items: "{{ command_result.stdout_lines }}"| 
> > > 
> > > 
> > > Expected output is: 
> > > 
> > > "msg": "User is user1" 
> > > "msg": "User is user2" 
> > > 
> > > 
> > > 
> > > Can you please suggest ?  
> > > 
> > 
> > Hello, 
> > 
> > what is the output that you actually get ... and please don't post 
> the same question twice. 
> > 
> > Regards 
> >  Racke 
> > 
> > > -- 
> > > 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/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com>
>  
>
> > > 
> > <
> https://groups.google.com/d/msgid/ansible-project/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com?utm_medium=email_source=footer
>  
> > <
> 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
@Stefan. The information provided by me is complete. 

The variable if not assigned a value defaults as "Hello World"

Reference: https://docs.ansible.com/ansible/latest/modules/debug_module.html

You can recreate the playbook output.

On Wednesday, September 25, 2019 at 2:23:22 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 10:44 AM, Mohtashim S wrote: 
> > @Stefan here is the output 
> > 
>
> Sorry but there is no "Hello world" in the tasks you posted. Providing 
> inaccurate information isn't helpful. 
>
> Regards 
>  Racke 
>
>
> > TASK [debug] 
> > 
> 
>  
>
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 
> > /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> > "msg": "User was FrontEnd" 
> > } 
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 
> > 367595418\n-rw-rw-r-- user2 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
> > /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 
> 15:38 /fin/com/testingcom.com 90193476
> > /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => { 
> > "msg": "User was BackEnd" 
> > } 
> > TASK [debug] 
> > 
> 
>  
>
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 
> > /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp  
>  FrontEnd) => { 
> > "msg": "Hello world!" 
> > } 
> > ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 
> > 367595418\n-rw-rw-r-- user2 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37 
> > /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 
> 15:38 /fin/com/testingcom.com 90193476
> > /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => { 
> > "msg": "Hello world!" 
> > } 
> > 
> > 
> > On Wednesday, September 25, 2019 at 1:40:38 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 9/25/19 9:58 AM, Mohtashim S wrote: 
> > > |   - debug: 
> > >msg: "User was {{ item.split('\t')[3] }}" 
> > >  with_items: "{{ command_result.stdout_lines }}"| 
> > > 
> > > 
> > > The above give me the below output: 
> > > 
> > > "msg": "User was FrontEnd" 
> > > "msg": "User was BackEnd" 
> > > 
> > > 
> > > I now wish to set USER variable as user1 is returned value is 
> FrontEnd else USER value should be user2. 
> > > 
> > > I dont know how to do this but below is my failing playbook.  
> > > 
> > > |   - debug: 
> > >  vars: 
> > > USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' 
> else 'user2' }}" 
> > > msg: "User is {{ USER }}" 
> > > 
> > >  with_items: "{{ command_result.stdout_lines }}"| 
> > > 
> > > 
> > > Expected output is: 
> > > 
> > > "msg": "User is user1" 
> > > "msg": "User is user2" 
> > > 
> > > 
> > > 
> > > Can you please suggest ?  
> > > 
> > 
> > Hello, 
> > 
> > what is the output that you actually get ... and please don't post 
> the same question twice. 
> > 
> > Regards 
> >  Racke 
> > 
> > > -- 
> > > 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/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com>
>  
>
> > > 
> > <
> https://groups.google.com/d/msgid/ansible-project/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com?utm_medium=email_source=footer
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/11286705-639c-43e2-8e0d-47080203cfc1%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 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Stefan Hornburg (Racke)
On 9/25/19 10:44 AM, Mohtashim S wrote:
> @Stefan here is the output
> 

Sorry but there is no "Hello world" in the tasks you posted. Providing 
inaccurate information isn't helpful.

Regards
 Racke


> TASK [debug]
> 
> 
> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39
> /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp   FrontEnd) 
> => {
>     "msg": "User was FrontEnd"
> }
> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr
> 367595418\n-rw-rw-r-- user2 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37
> /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 15:38 
> /fin/com/testingcom.com 90193476       
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>     "msg": "User was BackEnd"
> }
> TASK [debug]
> 
> 
> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39
> /was//testingjsp/testingcom.jsp 1786385840  /was//testingjsp   FrontEnd) 
> => {
>     "msg": "Hello world!"
> }
> ok: [localhost] => (item=10.12.1.13     10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr
> 367595418\n-rw-rw-r-- user2 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 
> 1251350031\n-rw-rw-r-- user2 2019-09-13 15:37
> /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 2019-09-13 15:38 
> /fin/com/testingcom.com 90193476       
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
>     "msg": "Hello world!"
> }
> 
> 
> On Wednesday, September 25, 2019 at 1:40:38 PM UTC+5:30, Stefan Hornburg 
> (Racke) wrote:
> 
> On 9/25/19 9:58 AM, Mohtashim S wrote:
> > |   - debug:
> >        msg: "User was {{ item.split('\t')[3] }}"
> >      with_items: "{{ command_result.stdout_lines }}"|
> >
> >
> > The above give me the below output:
> >
> >     "msg": "User was FrontEnd"
> >     "msg": "User was BackEnd"
> >
> >
> > I now wish to set USER variable as user1 is returned value is FrontEnd 
> else USER value should be user2.
> >
> > I dont know how to do this but below is my failing playbook. 
> >
> > |   - debug:
> >      vars:
> >         USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' else 
> 'user2' }}"
> >         msg: "User is {{ USER }}"
> >
> >      with_items: "{{ command_result.stdout_lines }}"|
> >
> >
> > Expected output is:
> >
> >     "msg": "User is user1"
> >     "msg": "User is user2"
> >
> >
> >
> > Can you please suggest ? 
> >
> 
> Hello,
> 
> what is the output that you actually get ... and please don't post the 
> same question twice.
> 
> Regards
>          Racke
> 
> > --
> > 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/11286705-639c-43e2-8e0d-47080203cfc1%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/d2354140-209e-4554-b057-95514e0ba08c%40googlegroups.com
> .


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
You 

Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
@Stefan here is the output

TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "User was FrontEnd"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com 90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "User was BackEnd"
> }
> TASK [debug] 
> 
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user1 
> 2019-09-13 15:39 /was//testingjsp/testingcom.jsp 1786385840  
> /was//testingjsp   FrontEnd) => {
> "msg": "Hello world!"
> }
> ok: [localhost] => (item=10.12.1.13 10.12.1.13\n-rw-rw-r-- user2 
> 2019-09-13 15:29 /fin/scripts/testingscr.scr 367595418\n-rw-rw-r-- user2 
> 2019-09-13 15:36 /fin/mrt/testingmrt.mrt 1251350031\n-rw-rw-r-- user2 
> 2019-09-13 15:37 /fin/exe/testingexe.exe 1390265645\n-rw-rw-r-- user2 
> 2019-09-13 15:38 /fin/com/testingcom.com 90193476
> /fin/scripts\n/fin/mrt\n/fin/exe\n/fin/com   BackEnd) => {
> "msg": "Hello world!"
> }
>

On Wednesday, September 25, 2019 at 1:40:38 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/25/19 9:58 AM, Mohtashim S wrote: 
> > |   - debug: 
> >msg: "User was {{ item.split('\t')[3] }}" 
> >  with_items: "{{ command_result.stdout_lines }}"| 
> > 
> > 
> > The above give me the below output: 
> > 
> > "msg": "User was FrontEnd" 
> > "msg": "User was BackEnd" 
> > 
> > 
> > I now wish to set USER variable as user1 is returned value is FrontEnd 
> else USER value should be user2. 
> > 
> > I dont know how to do this but below is my failing playbook.  
> > 
> > |   - debug: 
> >  vars: 
> > USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' else 
> 'user2' }}" 
> > msg: "User is {{ USER }}" 
> > 
> >  with_items: "{{ command_result.stdout_lines }}"| 
> > 
> > 
> > Expected output is: 
> > 
> > "msg": "User is user1" 
> > "msg": "User is user2" 
> > 
> > 
> > 
> > Can you please suggest ?  
> > 
>
> Hello, 
>
> what is the output that you actually get ... and please don't post the 
> same question twice. 
>
> Regards 
>  Racke 
>
> > -- 
> > 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/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/11286705-639c-43e2-8e0d-47080203cfc1%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/d2354140-209e-4554-b057-95514e0ba08c%40googlegroups.com.


Re: [ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Stefan Hornburg (Racke)
On 9/25/19 9:58 AM, Mohtashim S wrote:
> |   - debug:
>        msg: "User was {{ item.split('\t')[3] }}"
>      with_items: "{{ command_result.stdout_lines }}"|
> 
> 
> The above give me the below output:
> 
> "msg": "User was FrontEnd"
> "msg": "User was BackEnd"
> 
> 
> I now wish to set USER variable as user1 is returned value is FrontEnd else 
> USER value should be user2.
> 
> I dont know how to do this but below is my failing playbook. 
> 
> |   - debug:
>      vars:
>         USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' else 'user2' 
> }}"
>         msg: "User is {{ USER }}"
> 
>      with_items: "{{ command_result.stdout_lines }}"|
> 
> 
> Expected output is:
> 
> "msg": "User is user1"
> "msg": "User is user2"
> 
> 
> 
> Can you please suggest ? 
> 

Hello,

what is the output that you actually get ... and please don't post the same 
question twice.

Regards
 Racke

> -- 
> 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/11286705-639c-43e2-8e0d-47080203cfc1%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/d4b546bd-6ebc-9765-40e9-8c21060e83e5%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Assign and print variable inside a with_items loop based on condition.

2019-09-25 Thread Mohtashim S
   - debug:
   msg: "User was {{ item.split('\t')[3] }}"
 with_items: "{{ command_result.stdout_lines }}"


The above give me the below output:

"msg": "User was FrontEnd"
> "msg": "User was BackEnd"


I now wish to set USER variable as user1 is returned value is FrontEnd else 
USER value should be user2.

I dont know how to do this but below is my failing playbook. 

   - debug:
 vars:
USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' else 'user2' 
}}"
msg: "User is {{ USER }}"

 with_items: "{{ command_result.stdout_lines }}"


Expected output is:

"msg": "User is user1"
> "msg": "User is user2"



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/11286705-639c-43e2-8e0d-47080203cfc1%40googlegroups.com.


[ansible-project] Assign and print variable in Ansible loop with_items on consition.

2019-09-25 Thread Mohtashim S
   - debug:
   msg: "User was {{ item.split('\t')[3] }}"
 with_items: "{{ command_result.stdout_lines }}"


The above give me the below output:

"msg": "User was FrontEnd"
> "msg": "User was BackEnd"


I now wish to set USER variable as user1 is returned value is FrontEnd else 
USER value should be user2.

I dont know how to do this but below is my failing playbook. 

   - debug:
 vars:
USER: "{{ 'user1' if item.split('\t')[3] == 'FrontEnd' else 'user2' 
}}"
msg: "User is {{ USER }}"

 with_items: "{{ command_result.stdout_lines }}"


Expected output is:

"msg": "User is user1"
> "msg": "User is user2"


-- 
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/3a2f5c3e-e4d3-4157-8b38-a6bfdde43991%40googlegroups.com.