Re: [ansible-project] Need help with registered variable

2020-07-14 Thread Rahul Kumar
THanks Vlad !
I will use same !

Regards
Rahul

On Mon, 13 Jul 2020 at 19:47, Vladimir Botka  wrote:

> On Fri, 10 Jul 2020 17:24:05 +0530
> Rahul Kumar  wrote:
>
> > I have a task output like this:
> > - name: Print Response of status resource
> >   debug:
> > msg: " {{ result }}"
> >
> > ok: [node-3] => {
> > "msg": " {'msg': u'All items completed', 'changed': False, 'results':
> > [{'ansible_loop_var': u'item', 'failed': False, 'changed': False,
> > u'content': {u'body': None, u'node': u'node-3', u'allServicesLocked':
> True,
> > u'appServer': u'1', u'type': u'iMIME', u'data': True,]} "
> > }
>
> Use "yaml" callback plugin when you want to see complex structures. For
> example, this task
>
>   - debug:
>   var: result
>
> would give
>
>   shell> ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook test.yml
>
>   result:
> changed: false
> msg: All items completed
> results:
> - ansible_loop_var: item
>   changed: false
>   content:
> allServicesLocked: true
> appServer: '1'
> body: None
> data: true
> node: node-3
> type: iMIME
>   failed: false
>
> Then, it's easier to find an expression which you're probably looking for
>
>   - debug:
>   var: result.results.0.content.data
>
> HTH,
>
> -vlado
> --
> 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/CAGH8rEwzLscKb0_8y4kZx60LexkHwh-J3twYQXqkPp%2Br6-B0Og%40mail.gmail.com.


Re: [ansible-project] Need help with registered variable

2020-07-13 Thread Vladimir Botka
On Fri, 10 Jul 2020 17:24:05 +0530
Rahul Kumar  wrote:

> I have a task output like this:
> - name: Print Response of status resource
>   debug:
> msg: " {{ result }}"
> 
> ok: [node-3] => {
> "msg": " {'msg': u'All items completed', 'changed': False, 'results':
> [{'ansible_loop_var': u'item', 'failed': False, 'changed': False,
> u'content': {u'body': None, u'node': u'node-3', u'allServicesLocked': True,
> u'appServer': u'1', u'type': u'iMIME', u'data': True,]} "
> }

Use "yaml" callback plugin when you want to see complex structures. For
example, this task

  - debug:
  var: result

would give

  shell> ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook test.yml

  result:
changed: false
msg: All items completed
results:
- ansible_loop_var: item
  changed: false
  content:
allServicesLocked: true
appServer: '1'
body: None
data: true
node: node-3
type: iMIME
  failed: false

Then, it's easier to find an expression which you're probably looking for

  - debug:
  var: result.results.0.content.data

HTH,

-vlado
-- 
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/20200713161701.227fa9d9%40gmail.com.


pgpik9CZv4CPK.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Need help with registered variable

2020-07-13 Thread Rahul Kumar
Notice, result is registered with loop ! So wanted to check in case of loop
does registered variable contains result of each iteration ?

On Mon, 13 Jul 2020 at 16:19, Rahul Kumar  wrote:

> No even it complains  results is not defined !
>
> I am not understanding whats wrong here :
> Here is the task:
> - name: print boss
>   debug:
>msg: " {{ result }}"
>
> and output is:
> ok: [node-1] => {
> "msg": " {'msg': u'All items completed', 'changed': False, 'results':
> [{'ansible_loop_var': u'item', 'failed': False, 'changed': False,
> u'content': {u'body': None, u'node': u'node-1', u'isFetched': True,
> u'appServer': u'1', u'type': u'appServerFullStatus', u'allServicesEnabled':
>
> I need to reach upto isFetched in this json ?
>
> On Fri, 10 Jul 2020 at 22:12, Srinivas Naram 
> wrote:
>
>> Try by removing  quotes
>>
>> result[results][0].content.data
>>
>> On Fri, Jul 10, 2020 at 8:04 PM Rahul Kumar 
>> wrote:
>>
>>> Thanks Abhijeet ! I tried even result[‘results’][0].content.data but
>>> still it complains results is not dict attribute !
>>>
>>> On Fri, 10 Jul 2020 at 5:32 PM, Abhijeet Kasurde 
>>> wrote:
>>>
 'data' is inside 'content' you might want to check around that


 On Fri, Jul 10, 2020 at 5:24 PM Rahul Kumar 
 wrote:

> I have a task output like this:
> - name: Print Response of status resource
>   debug:
> msg: " {{ result }}"
>
> ok: [node-3] => {
> "msg": " {'msg': u'All items completed', 'changed': False,
> 'results': [{'ansible_loop_var': u'item', 'failed': False, 'changed':
> False, u'content': {u'body': None, u'node': u'node-3',
> u'allServicesLocked': True, u'appServer': u'1', u'type': u'iMIME', 
> u'data':
> True,]} "
> }
>
> But when i try to access like that in some task, it does not work:
> until : result['results'].data == True   , it complains saying dict
> does not have results attribute !
> Here result is my registered variable. As per above response , it
> should work fine ?
>
>
> --
> 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/CAGH8rEyOHqmrA7diB3AznLqRncRaj_r539gA5-oZpkEwMrzwCA%40mail.gmail.com
> 
> .


>

 --
 Thanks,
 Abhijeet Kasurde

 --
 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/CAFwWkHpb0WcE8jKLcPsM2i1mzA_PX%2BGBRF7Jtefqtmp4wFC6Sw%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/CAGH8rEwgRWxNLYf1WaxNyqb7e0gmEDyC4nMZnw_0wwUJa32_ew%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-N3P7fK4PGzb7OKmfSyvsSB9tLSmipVNLoPW%3DPdfe7EwGzTA%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/CAGH8rEwgSgFcWFm_mEo9BijZVCAAELjjgroe9WOuVM4YDVusaQ%40mail.gmail.com.


Re: [ansible-project] Need help with registered variable

2020-07-13 Thread Rahul Kumar
No even it complains  results is not defined !

I am not understanding whats wrong here :
Here is the task:
- name: print boss
  debug:
   msg: " {{ result }}"

and output is:
ok: [node-1] => {
"msg": " {'msg': u'All items completed', 'changed': False, 'results':
[{'ansible_loop_var': u'item', 'failed': False, 'changed': False,
u'content': {u'body': None, u'node': u'node-1', u'isFetched': True,
u'appServer': u'1', u'type': u'appServerFullStatus', u'allServicesEnabled':

I need to reach upto isFetched in this json ?

On Fri, 10 Jul 2020 at 22:12, Srinivas Naram 
wrote:

> Try by removing  quotes
>
> result[results][0].content.data
>
> On Fri, Jul 10, 2020 at 8:04 PM Rahul Kumar 
> wrote:
>
>> Thanks Abhijeet ! I tried even result[‘results’][0].content.data but
>> still it complains results is not dict attribute !
>>
>> On Fri, 10 Jul 2020 at 5:32 PM, Abhijeet Kasurde 
>> wrote:
>>
>>> 'data' is inside 'content' you might want to check around that
>>>
>>>
>>> On Fri, Jul 10, 2020 at 5:24 PM Rahul Kumar 
>>> wrote:
>>>
 I have a task output like this:
 - name: Print Response of status resource
   debug:
 msg: " {{ result }}"

 ok: [node-3] => {
 "msg": " {'msg': u'All items completed', 'changed': False,
 'results': [{'ansible_loop_var': u'item', 'failed': False, 'changed':
 False, u'content': {u'body': None, u'node': u'node-3',
 u'allServicesLocked': True, u'appServer': u'1', u'type': u'iMIME', u'data':
 True,]} "
 }

 But when i try to access like that in some task, it does not work:
 until : result['results'].data == True   , it complains saying dict
 does not have results attribute !
 Here result is my registered variable. As per above response , it
 should work fine ?


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

>>>
>>> --
>>> Thanks,
>>> Abhijeet Kasurde
>>>
>>> --
>>> 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/CAFwWkHpb0WcE8jKLcPsM2i1mzA_PX%2BGBRF7Jtefqtmp4wFC6Sw%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/CAGH8rEwgRWxNLYf1WaxNyqb7e0gmEDyC4nMZnw_0wwUJa32_ew%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-N3P7fK4PGzb7OKmfSyvsSB9tLSmipVNLoPW%3DPdfe7EwGzTA%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/CAGH8rEy6ccndi1Qr3FpJFn9W-5L%3DxuSQaWSkNvJ7eNZ7e5MPLA%40mail.gmail.com.


Re: [ansible-project] Need help with registered variable

2020-07-10 Thread Srinivas Naram
Try by removing  quotes

result[results][0].content.data

On Fri, Jul 10, 2020 at 8:04 PM Rahul Kumar  wrote:

> Thanks Abhijeet ! I tried even result[‘results’][0].content.data but still
> it complains results is not dict attribute !
>
> On Fri, 10 Jul 2020 at 5:32 PM, Abhijeet Kasurde 
> wrote:
>
>> 'data' is inside 'content' you might want to check around that
>>
>>
>> On Fri, Jul 10, 2020 at 5:24 PM Rahul Kumar 
>> wrote:
>>
>>> I have a task output like this:
>>> - name: Print Response of status resource
>>>   debug:
>>> msg: " {{ result }}"
>>>
>>> ok: [node-3] => {
>>> "msg": " {'msg': u'All items completed', 'changed': False,
>>> 'results': [{'ansible_loop_var': u'item', 'failed': False, 'changed':
>>> False, u'content': {u'body': None, u'node': u'node-3',
>>> u'allServicesLocked': True, u'appServer': u'1', u'type': u'iMIME', u'data':
>>> True,]} "
>>> }
>>>
>>> But when i try to access like that in some task, it does not work:
>>> until : result['results'].data == True   , it complains saying dict does
>>> not have results attribute !
>>> Here result is my registered variable. As per above response , it should
>>> work fine ?
>>>
>>>
>>> --
>>> 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/CAGH8rEyOHqmrA7diB3AznLqRncRaj_r539gA5-oZpkEwMrzwCA%40mail.gmail.com
>>> 
>>> .
>>
>>
>>>
>>
>> --
>> Thanks,
>> Abhijeet Kasurde
>>
>> --
>> 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/CAFwWkHpb0WcE8jKLcPsM2i1mzA_PX%2BGBRF7Jtefqtmp4wFC6Sw%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/CAGH8rEwgRWxNLYf1WaxNyqb7e0gmEDyC4nMZnw_0wwUJa32_ew%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-N3P7fK4PGzb7OKmfSyvsSB9tLSmipVNLoPW%3DPdfe7EwGzTA%40mail.gmail.com.


Re: [ansible-project] Need help with registered variable

2020-07-10 Thread Rahul Kumar
Thanks Abhijeet ! I tried even result[‘results’][0].content.data but still
it complains results is not dict attribute !

On Fri, 10 Jul 2020 at 5:32 PM, Abhijeet Kasurde 
wrote:

> 'data' is inside 'content' you might want to check around that
>
>
> On Fri, Jul 10, 2020 at 5:24 PM Rahul Kumar 
> wrote:
>
>> I have a task output like this:
>> - name: Print Response of status resource
>>   debug:
>> msg: " {{ result }}"
>>
>> ok: [node-3] => {
>> "msg": " {'msg': u'All items completed', 'changed': False, 'results':
>> [{'ansible_loop_var': u'item', 'failed': False, 'changed': False,
>> u'content': {u'body': None, u'node': u'node-3', u'allServicesLocked': True,
>> u'appServer': u'1', u'type': u'iMIME', u'data': True,]} "
>> }
>>
>> But when i try to access like that in some task, it does not work:
>> until : result['results'].data == True   , it complains saying dict does
>> not have results attribute !
>> Here result is my registered variable. As per above response , it should
>> work fine ?
>>
>>
>> --
>> 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/CAGH8rEyOHqmrA7diB3AznLqRncRaj_r539gA5-oZpkEwMrzwCA%40mail.gmail.com
>> 
>> .
>
>
>>
>
> --
> Thanks,
> Abhijeet Kasurde
>
> --
> 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/CAFwWkHpb0WcE8jKLcPsM2i1mzA_PX%2BGBRF7Jtefqtmp4wFC6Sw%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/CAGH8rEwgRWxNLYf1WaxNyqb7e0gmEDyC4nMZnw_0wwUJa32_ew%40mail.gmail.com.


Re: [ansible-project] Need help with registered variable

2020-07-10 Thread Abhijeet Kasurde
'data' is inside 'content' you might want to check around that


On Fri, Jul 10, 2020 at 5:24 PM Rahul Kumar  wrote:

> I have a task output like this:
> - name: Print Response of status resource
>   debug:
> msg: " {{ result }}"
>
> ok: [node-3] => {
> "msg": " {'msg': u'All items completed', 'changed': False, 'results':
> [{'ansible_loop_var': u'item', 'failed': False, 'changed': False,
> u'content': {u'body': None, u'node': u'node-3', u'allServicesLocked': True,
> u'appServer': u'1', u'type': u'iMIME', u'data': True,]} "
> }
>
> But when i try to access like that in some task, it does not work:
> until : result['results'].data == True   , it complains saying dict does
> not have results attribute !
> Here result is my registered variable. As per above response , it should
> work fine ?
>
>
> --
> 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/CAGH8rEyOHqmrA7diB3AznLqRncRaj_r539gA5-oZpkEwMrzwCA%40mail.gmail.com
> 
> .
>


-- 
Thanks,
Abhijeet Kasurde

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