Re: [ansible-project] How to split value from list

2020-07-07 Thread Srinivas Naram
How do we incorporate if-else in set_fact ?

On Tue, Jul 7, 2020 at 11:26 AM Jenisha T  wrote:

> This logic works. Thankyou
>
> On Tuesday, 7 July 2020 at 10:52:51 UTC+5:30 Karl Auer wrote:
>
>> so what's wrong with:
>>
>> USR="jenisha"
>> FOUND=`grep $USR /etc/passwd | cut -d: -f1`
>> if [ -z "$FOUND" ] ; then
>>echo "No such user: $USR"
>> else
>># do whatever...
>> fi
>>
>> ?
>>
>> Regards, K.
>>
>>
>> On Tue, Jul 7, 2020 at 3:11 PM T. JENISHA  wrote:
>>
>>> In my case cut doesn't work. I m searching for a particular user from a
>>> password.
>>> $ grep anil /etc/passwd
>>>
>>>
>>> Best Regards
>>> Jenisha T
>>> Whatsapp: +91 07598087866 <+91%2075980%2087866>
>>>
>>>
>>>
>>>
>>>
>>> On Mon, 6 Jul 2020 at 19:50, Stefan Hornburg (Racke) 
>>> wrote:
>>>
 On 7/6/20 3:32 PM, Srinivas Naram wrote:
 > Hello Jenisha,
 >
 > Assuming that you are getting this value from /etc/passwd., try to
 change you command
 >
 >  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
 >

 cut -d : -f 1 is more concise and readable than your awk command.

 Otherwise I would really like to know why Jenisha resorts to reading
 the password file.

 Regards
  racke


 > On Mon, Jul 6, 2020 at 6:35 PM Dick Visser >>> > wrote:
 >
 > you should either use set_fact, or register. Both doesn't make
 sense.
 >
 > On Mon, 6 Jul 2020 at 13:44, Jenisha T >>> joy...@gmail.com>> wrote:
 > >
 > > Hi
 > > Could you pls help me with the splitting value from the list. I
 need to extract first value anil before ('':')
 > >
 > >  grep_atm.stdout_lines output below
 > >
 > > ok: [localhost] => {
 > > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
 > > "
 > > }
 > >
 > > I tried,
 > > - set_fact:
 > >user_name: "{{ grep_atm.stdout_lines }}"
 > > register: user_name.split(':')[0]
 > >  - debug:
 > > var: user_name.split(':')[0]
 > >
 > > --
 > > You received this message because you are subscribed to the
 Google Groups "Ansible Project" group.
 > > To unsubscribe from this group and stop receiving emails from
 it, send an email to
 > ansible-proje...@googlegroups.com >>> ansible-project%2bunsu...@googlegroups.com>.
 > > To view this discussion on the web visit
 >
 https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
 .
 >
 >
 >
 > --
 > Dick Visser
 > Trust & Identity Service Operations Manager
 > GÉANT
 >
 > --
 > You received this message because you are subscribed to the
 Google Groups "Ansible Project" group.
 > To unsubscribe from this group and stop receiving emails from it,
 send an email to
 > ansible-proje...@googlegroups.com >>> ansible-project%2bunsu...@googlegroups.com>.
 > To view this discussion on the web visit
 >
 https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
 .
 >
 > --
 > You received this message because you are subscribed to the Google
 Groups "Ansible Project" group.
 > To unsubscribe from this group and stop receiving emails from it,
 send an email to
 > ansible-proje...@googlegroups.com >>> ansible-proje...@googlegroups.com>.
 > To view this discussion on the web visit
 >
 https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com
 > <
 https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.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-proje...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/ansible-project/b4c85876-5359-f104-cd6f-03667cd7f93b%40linuxia.de
 .

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible-proje...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/CAAGhZYjxvOgKKa1pFfh5oAp2JDzyeOmW0SE8zFM_j3vTefgaUw%40mail.gmail.com
>>> 

Re: [ansible-project] How to split value from list

2020-07-06 Thread Jenisha T
This logic works. Thankyou

On Tuesday, 7 July 2020 at 10:52:51 UTC+5:30 Karl Auer wrote:

> so what's wrong with:
>
> USR="jenisha"
> FOUND=`grep $USR /etc/passwd | cut -d: -f1`
> if [ -z "$FOUND" ] ; then
>echo "No such user: $USR"
> else
># do whatever...
> fi
>
> ?
>
> Regards, K.
>
>
> On Tue, Jul 7, 2020 at 3:11 PM T. JENISHA  wrote:
>
>> In my case cut doesn't work. I m searching for a particular user from a 
>> password.
>> $ grep anil /etc/passwd
>>
>>
>> Best Regards
>> Jenisha T
>> Whatsapp: +91 07598087866 <+91%2075980%2087866>
>>
>>
>>
>>
>>
>> On Mon, 6 Jul 2020 at 19:50, Stefan Hornburg (Racke)  
>> wrote:
>>
>>> On 7/6/20 3:32 PM, Srinivas Naram wrote:
>>> > Hello Jenisha,
>>> > 
>>> > Assuming that you are getting this value from /etc/passwd., try to 
>>> change you command
>>> > 
>>> >  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
>>> > 
>>>
>>> cut -d : -f 1 is more concise and readable than your awk command.
>>>
>>> Otherwise I would really like to know why Jenisha resorts to reading the 
>>> password file.
>>>
>>> Regards
>>>  racke
>>>
>>>
>>> > On Mon, Jul 6, 2020 at 6:35 PM Dick Visser >> > wrote:
>>> > 
>>> > you should either use set_fact, or register. Both doesn't make 
>>> sense.
>>> > 
>>> > On Mon, 6 Jul 2020 at 13:44, Jenisha T >> joy...@gmail.com>> wrote:
>>> > >
>>> > > Hi
>>> > > Could you pls help me with the splitting value from the list. I 
>>> need to extract first value anil before ('':')
>>> > >
>>> > >  grep_atm.stdout_lines output below
>>> > >
>>> > > ok: [localhost] => {
>>> > > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
>>> > > "
>>> > > }
>>> > >
>>> > > I tried,
>>> > > - set_fact:
>>> > >user_name: "{{ grep_atm.stdout_lines }}"
>>> > > register: user_name.split(':')[0]
>>> > >  - debug:
>>> > > var: user_name.split(':')[0]
>>> > >
>>> > > --
>>> > > You received this message because you are subscribed to the 
>>> Google Groups "Ansible Project" group.
>>> > > To unsubscribe from this group and stop receiving emails from 
>>> it, send an email to
>>> > ansible-proje...@googlegroups.com >> ansible-project%2bunsu...@googlegroups.com>.
>>> > > To view this discussion on the web visit
>>> > 
>>> https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
>>> .
>>> > 
>>> > 
>>> > 
>>> > -- 
>>> > Dick Visser
>>> > Trust & Identity Service Operations Manager
>>> > GÉANT
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> Groups "Ansible Project" group.
>>> > To unsubscribe from this group and stop receiving emails from it, 
>>> send an email to
>>> > ansible-proje...@googlegroups.com >> ansible-project%2bunsu...@googlegroups.com>.
>>> > To view this discussion on the web visit
>>> > 
>>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
>>> .
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> Groups "Ansible Project" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to
>>> > ansible-proje...@googlegroups.com >> ansible-proje...@googlegroups.com>.
>>> > To view this discussion on the web visit
>>> > 
>>> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com
>>> > <
>>> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.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-proje...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/b4c85876-5359-f104-cd6f-03667cd7f93b%40linuxia.de
>>> .
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible-proje...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/CAAGhZYjxvOgKKa1pFfh5oAp2JDzyeOmW0SE8zFM_j3vTefgaUw%40mail.gmail.com
>>  
>> 
>> .
>>
>
>
> -- 
>
> *Karl Auer* { manager, systems support }
> P: 1300 759 975
> E: 

Re: [ansible-project] How to split value from list

2020-07-06 Thread T. JENISHA
Thank you, everyone, grep followed by cut gave me desired output



Best Regards
Jenisha T
Whatsapp: +91 07598087866





On Mon, 6 Jul 2020 at 19:50, Stefan Hornburg (Racke) 
wrote:

> On 7/6/20 3:32 PM, Srinivas Naram wrote:
> > Hello Jenisha,
> >
> > Assuming that you are getting this value from /etc/passwd., try to
> change you command
> >
> >  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
> >
>
> cut -d : -f 1 is more concise and readable than your awk command.
>
> Otherwise I would really like to know why Jenisha resorts to reading the
> password file.
>
> Regards
>  racke
>
>
> > On Mon, Jul 6, 2020 at 6:35 PM Dick Visser  > wrote:
> >
> > you should either use set_fact, or register. Both doesn't make sense.
> >
> > On Mon, 6 Jul 2020 at 13:44, Jenisha T  joyj...@gmail.com>> wrote:
> > >
> > > Hi
> > > Could you pls help me with the splitting value from the list. I
> need to extract first value anil before ('':')
> > >
> > >  grep_atm.stdout_lines output below
> > >
> > > ok: [localhost] => {
> > > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
> > > "
> > > }
> > >
> > > I tried,
> > > - set_fact:
> > >user_name: "{{ grep_atm.stdout_lines }}"
> > > register: user_name.split(':')[0]
> > >  - debug:
> > > var: user_name.split(':')[0]
> > >
> > > --
> > > 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  ansible-project%2bunsubscr...@googlegroups.com>.
> > > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
> .
> >
> >
> >
> > --
> > Dick Visser
> > Trust & Identity Service Operations Manager
> > GÉANT
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send an email to
> > ansible-project+unsubscr...@googlegroups.com  ansible-project%2bunsubscr...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
> .
> >
> > --
> > 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  ansible-project+unsubscr...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com
> > <
> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.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/b4c85876-5359-f104-cd6f-03667cd7f93b%40linuxia.de
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAAGhZYhrp1iWGeOY%2BD9ns0J3nVeLA9BGvjVnMEOW75CxygXxQQ%40mail.gmail.com.


Re: [ansible-project] How to split value from list

2020-07-06 Thread Srinivas Naram
Did you try this ?

 user_name: "{{ my_string[0].split(':')[0] }}"

On Tue, Jul 7, 2020 at 10:52 AM Karl Auer  wrote:

> so what's wrong with:
>
> USR="jenisha"
> FOUND=`grep $USR /etc/passwd | cut -d: -f1`
> if [ -z "$FOUND" ] ; then
>echo "No such user: $USR"
> else
># do whatever...
> fi
>
> ?
>
> Regards, K.
>
>
> On Tue, Jul 7, 2020 at 3:11 PM T. JENISHA  wrote:
>
>> In my case cut doesn't work. I m searching for a particular user from a
>> password.
>> $ grep anil /etc/passwd
>>
>>
>> Best Regards
>> Jenisha T
>> Whatsapp: +91 07598087866
>>
>>
>>
>>
>>
>> On Mon, 6 Jul 2020 at 19:50, Stefan Hornburg (Racke) 
>> wrote:
>>
>>> On 7/6/20 3:32 PM, Srinivas Naram wrote:
>>> > Hello Jenisha,
>>> >
>>> > Assuming that you are getting this value from /etc/passwd., try to
>>> change you command
>>> >
>>> >  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
>>> >
>>>
>>> cut -d : -f 1 is more concise and readable than your awk command.
>>>
>>> Otherwise I would really like to know why Jenisha resorts to reading the
>>> password file.
>>>
>>> Regards
>>>  racke
>>>
>>>
>>> > On Mon, Jul 6, 2020 at 6:35 PM Dick Visser >> > wrote:
>>> >
>>> > you should either use set_fact, or register. Both doesn't make
>>> sense.
>>> >
>>> > On Mon, 6 Jul 2020 at 13:44, Jenisha T >> joyj...@gmail.com>> wrote:
>>> > >
>>> > > Hi
>>> > > Could you pls help me with the splitting value from the list. I
>>> need to extract first value anil before ('':')
>>> > >
>>> > >  grep_atm.stdout_lines output below
>>> > >
>>> > > ok: [localhost] => {
>>> > > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
>>> > > "
>>> > > }
>>> > >
>>> > > I tried,
>>> > > - set_fact:
>>> > >user_name: "{{ grep_atm.stdout_lines }}"
>>> > > register: user_name.split(':')[0]
>>> > >  - debug:
>>> > > var: user_name.split(':')[0]
>>> > >
>>> > > --
>>> > > 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 >> ansible-project%2bunsubscr...@googlegroups.com>.
>>> > > To view this discussion on the web visit
>>> >
>>> https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
>>> .
>>> >
>>> >
>>> >
>>> > --
>>> > Dick Visser
>>> > Trust & Identity Service Operations Manager
>>> > GÉANT
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> > To unsubscribe from this group and stop receiving emails from it,
>>> send an email to
>>> > ansible-project+unsubscr...@googlegroups.com >> ansible-project%2bunsubscr...@googlegroups.com>.
>>> > To view this discussion on the web visit
>>> >
>>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
>>> .
>>> >
>>> > --
>>> > 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 >> ansible-project+unsubscr...@googlegroups.com>.
>>> > To view this discussion on the web visit
>>> >
>>> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com
>>> > <
>>> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.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/b4c85876-5359-f104-cd6f-03667cd7f93b%40linuxia.de
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAAGhZYjxvOgKKa1pFfh5oAp2JDzyeOmW0SE8zFM_j3vTefgaUw%40mail.gmail.com
>> 
>> .
>>
>
>
> --
>
> *Karl Auer* { manager, systems support }

Re: [ansible-project] How to split value from list

2020-07-06 Thread Karl Auer
so what's wrong with:

USR="jenisha"
FOUND=`grep $USR /etc/passwd | cut -d: -f1`
if [ -z "$FOUND" ] ; then
   echo "No such user: $USR"
else
   # do whatever...
fi

?

Regards, K.


On Tue, Jul 7, 2020 at 3:11 PM T. JENISHA  wrote:

> In my case cut doesn't work. I m searching for a particular user from a
> password.
> $ grep anil /etc/passwd
>
>
> Best Regards
> Jenisha T
> Whatsapp: +91 07598087866
>
>
>
>
>
> On Mon, 6 Jul 2020 at 19:50, Stefan Hornburg (Racke) 
> wrote:
>
>> On 7/6/20 3:32 PM, Srinivas Naram wrote:
>> > Hello Jenisha,
>> >
>> > Assuming that you are getting this value from /etc/passwd., try to
>> change you command
>> >
>> >  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
>> >
>>
>> cut -d : -f 1 is more concise and readable than your awk command.
>>
>> Otherwise I would really like to know why Jenisha resorts to reading the
>> password file.
>>
>> Regards
>>  racke
>>
>>
>> > On Mon, Jul 6, 2020 at 6:35 PM Dick Visser > > wrote:
>> >
>> > you should either use set_fact, or register. Both doesn't make
>> sense.
>> >
>> > On Mon, 6 Jul 2020 at 13:44, Jenisha T > joyj...@gmail.com>> wrote:
>> > >
>> > > Hi
>> > > Could you pls help me with the splitting value from the list. I
>> need to extract first value anil before ('':')
>> > >
>> > >  grep_atm.stdout_lines output below
>> > >
>> > > ok: [localhost] => {
>> > > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
>> > > "
>> > > }
>> > >
>> > > I tried,
>> > > - set_fact:
>> > >user_name: "{{ grep_atm.stdout_lines }}"
>> > > register: user_name.split(':')[0]
>> > >  - debug:
>> > > var: user_name.split(':')[0]
>> > >
>> > > --
>> > > 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 > ansible-project%2bunsubscr...@googlegroups.com>.
>> > > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
>> .
>> >
>> >
>> >
>> > --
>> > Dick Visser
>> > Trust & Identity Service Operations Manager
>> > GÉANT
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Ansible Project" group.
>> > To unsubscribe from this group and stop receiving emails from it,
>> send an email to
>> > ansible-project+unsubscr...@googlegroups.com > ansible-project%2bunsubscr...@googlegroups.com>.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
>> .
>> >
>> > --
>> > 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 > ansible-project+unsubscr...@googlegroups.com>.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com
>> > <
>> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.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/b4c85876-5359-f104-cd6f-03667cd7f93b%40linuxia.de
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAAGhZYjxvOgKKa1pFfh5oAp2JDzyeOmW0SE8zFM_j3vTefgaUw%40mail.gmail.com
> 
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.

Re: [ansible-project] How to split value from list

2020-07-06 Thread T. JENISHA
In my case cut doesn't work. I m searching for a particular user from a
password.
$ grep anil /etc/passwd


Best Regards
Jenisha T
Whatsapp: +91 07598087866





On Mon, 6 Jul 2020 at 19:50, Stefan Hornburg (Racke) 
wrote:

> On 7/6/20 3:32 PM, Srinivas Naram wrote:
> > Hello Jenisha,
> >
> > Assuming that you are getting this value from /etc/passwd., try to
> change you command
> >
> >  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
> >
>
> cut -d : -f 1 is more concise and readable than your awk command.
>
> Otherwise I would really like to know why Jenisha resorts to reading the
> password file.
>
> Regards
>  racke
>
>
> > On Mon, Jul 6, 2020 at 6:35 PM Dick Visser  > wrote:
> >
> > you should either use set_fact, or register. Both doesn't make sense.
> >
> > On Mon, 6 Jul 2020 at 13:44, Jenisha T  joyj...@gmail.com>> wrote:
> > >
> > > Hi
> > > Could you pls help me with the splitting value from the list. I
> need to extract first value anil before ('':')
> > >
> > >  grep_atm.stdout_lines output below
> > >
> > > ok: [localhost] => {
> > > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
> > > "
> > > }
> > >
> > > I tried,
> > > - set_fact:
> > >user_name: "{{ grep_atm.stdout_lines }}"
> > > register: user_name.split(':')[0]
> > >  - debug:
> > > var: user_name.split(':')[0]
> > >
> > > --
> > > 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  ansible-project%2bunsubscr...@googlegroups.com>.
> > > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
> .
> >
> >
> >
> > --
> > Dick Visser
> > Trust & Identity Service Operations Manager
> > GÉANT
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send an email to
> > ansible-project+unsubscr...@googlegroups.com  ansible-project%2bunsubscr...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
> .
> >
> > --
> > 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  ansible-project+unsubscr...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com
> > <
> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.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/b4c85876-5359-f104-cd6f-03667cd7f93b%40linuxia.de
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAAGhZYjxvOgKKa1pFfh5oAp2JDzyeOmW0SE8zFM_j3vTefgaUw%40mail.gmail.com.


Re: [ansible-project] How to split value from list

2020-07-06 Thread T. JENISHA
Hi Team
I get below error when I use split directly,

The error was: 'list object' has no attribute 'split'

How to unlist in ansible


Best Regards
Jenisha T
Whatsapp: +91 07598087866





On Mon, 6 Jul 2020 at 20:27, Vladimir Botka  wrote:

> On Mon, 6 Jul 2020 04:44:18 -0700 (PDT)
> Jenisha T  wrote:
>
> > extract first value* anil *before (':')
> >
> > "msg": "*anil*:x:500:500:Anil:/home/anil:/bin/bash
> >
>
>user_name: "{{ my_string.split(':')[0] }}"
>
> This is the correct expression, given the data is in the variable
> "my_string",
> wherever it might come from.
>
> --
> Vladimir Botka
>

-- 
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/CAAGhZYj0ksGSgcyXJeQYezWjPTuGt9yA9AptqRWuwYhnt_92cg%40mail.gmail.com.


Re: [ansible-project] How to split value from list

2020-07-06 Thread Vladimir Botka
On Mon, 6 Jul 2020 04:44:18 -0700 (PDT)
Jenisha T  wrote:

> extract first value* anil *before (':')
>
> "msg": "*anil*:x:500:500:Anil:/home/anil:/bin/bash
>

   user_name: "{{ my_string.split(':')[0] }}"

This is the correct expression, given the data is in the variable "my_string",
wherever it might come from.

-- 
Vladimir Botka

-- 
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/20200706165717.0fa53926%40gmail.com.


pgpghlnoi_M81.pgp
Description: OpenPGP digital signature


Re: [ansible-project] How to split value from list

2020-07-06 Thread Stefan Hornburg (Racke)
On 7/6/20 3:32 PM, Srinivas Naram wrote:
> Hello Jenisha,
> 
> Assuming that you are getting this value from /etc/passwd., try to change you 
> command
> 
>  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
> 

cut -d : -f 1 is more concise and readable than your awk command.

Otherwise I would really like to know why Jenisha resorts to reading the 
password file.

Regards
 racke


> On Mon, Jul 6, 2020 at 6:35 PM Dick Visser  > wrote:
> 
> you should either use set_fact, or register. Both doesn't make sense.
> 
> On Mon, 6 Jul 2020 at 13:44, Jenisha T  > wrote:
> >
> > Hi
> > Could you pls help me with the splitting value from the list. I need to 
> extract first value anil before ('':')
> >
> >  grep_atm.stdout_lines output below
> >
> > ok: [localhost] => {
> >     "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
> > "
> > }
> >
> > I tried,
> > - set_fact:
> >        user_name: "{{ grep_atm.stdout_lines }}"
> >         register: user_name.split(':')[0]
> >  - debug:
> >         var: user_name.split(':')[0]
> >
> > --
> > 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/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com.
> 
> 
> 
> -- 
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to
> ansible-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com.
> 
> -- 
> 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-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.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/b4c85876-5359-f104-cd6f-03667cd7f93b%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


Re: [ansible-project] How to split value from list

2020-07-06 Thread Srinivas Naram
Hello Jenisha,

Assuming that you are getting this value from /etc/passwd., try to change
you command

 tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'

On Mon, Jul 6, 2020 at 6:35 PM Dick Visser  wrote:

> you should either use set_fact, or register. Both doesn't make sense.
>
> On Mon, 6 Jul 2020 at 13:44, Jenisha T  wrote:
> >
> > Hi
> > Could you pls help me with the splitting value from the list. I need to
> extract first value anil before ('':')
> >
> >  grep_atm.stdout_lines output below
> >
> > ok: [localhost] => {
> > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
> > "
> > }
> >
> > I tried,
> > - set_fact:
> >user_name: "{{ grep_atm.stdout_lines }}"
> > register: user_name.split(':')[0]
> >  - debug:
> > var: user_name.split(':')[0]
> >
> > --
> > 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/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
> .
>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
> .
>

-- 
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-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com.


Re: [ansible-project] How to split value from list

2020-07-06 Thread Dick Visser
you should either use set_fact, or register. Both doesn't make sense.

On Mon, 6 Jul 2020 at 13:44, Jenisha T  wrote:
>
> Hi
> Could you pls help me with the splitting value from the list. I need to 
> extract first value anil before ('':')
>
>  grep_atm.stdout_lines output below
>
> ok: [localhost] => {
> "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
> "
> }
>
> I tried,
> - set_fact:
>user_name: "{{ grep_atm.stdout_lines }}"
> register: user_name.split(':')[0]
>  - debug:
> var: user_name.split(':')[0]
>
> --
> 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/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com.



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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com.


Re: [ansible-project] How to split value from list

2020-07-06 Thread T. JENISHA
It supports only for the database. My output in register
Best Regards
Jenisha T
Whatsapp: +91 07598087866





On Mon, 6 Jul 2020 at 17:19, Dick Visser  wrote:

> Based on your data, look at this module:
> https://docs.ansible.com/ansible/latest/modules/getent_module.html
>
> On Mon, 6 Jul 2020 at 13:44, Jenisha T  wrote:
> >
> > Hi
> > Could you pls help me with the splitting value from the list. I need to
> extract first value anil before ('':')
> >
> >  grep_atm.stdout_lines output below
> >
> > ok: [localhost] => {
> > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
> > "
> > }
> >
> > I tried,
> > - set_fact:
> >user_name: "{{ grep_atm.stdout_lines }}"
> > register: user_name.split(':')[0]
> >  - debug:
> > var: user_name.split(':')[0]
> >
> > --
> > 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/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
> .
>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwNuqWXVNjms%3DaAcLs%2BppZitE%3DrzLjdP9fQJDdsDq-jXuw%40mail.gmail.com
> .
>

-- 
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/CAAGhZYhiDdDCRrGkKOeOKOUMwj1NNL%2BtxUCmURvyM4yxktyrvA%40mail.gmail.com.


Re: [ansible-project] How to split value from list

2020-07-06 Thread Dick Visser
Based on your data, look at this module:
https://docs.ansible.com/ansible/latest/modules/getent_module.html

On Mon, 6 Jul 2020 at 13:44, Jenisha T  wrote:
>
> Hi
> Could you pls help me with the splitting value from the list. I need to 
> extract first value anil before ('':')
>
>  grep_atm.stdout_lines output below
>
> ok: [localhost] => {
> "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
> "
> }
>
> I tried,
> - set_fact:
>user_name: "{{ grep_atm.stdout_lines }}"
> register: user_name.split(':')[0]
>  - debug:
> var: user_name.split(':')[0]
>
> --
> 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/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com.



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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwNuqWXVNjms%3DaAcLs%2BppZitE%3DrzLjdP9fQJDdsDq-jXuw%40mail.gmail.com.


[ansible-project] How to split value from list

2020-07-06 Thread Jenisha T
Hi 
Could you pls help me with the splitting value from the list. I need to 
extract first value* anil *before ('':')

* grep_atm.stdout_lines* output below

ok: [localhost] => {
"msg": "*anil*:x:500:500:Anil:/home/anil:/bin/bash
"
}

I tried,
- set_fact:  
   user_name: "{{ grep_atm.stdout_lines }}"
register: user_name.split(':')[0]  
 - debug:
var: user_name.split(':')[0]

-- 
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/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com.