# Experts help need for imc\_rest module

**URL:** <https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362>\
**Category:** Ansible Project\
**Created:** [December 21, 2020, 7:04pm UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362 "2020-12-21T19:04:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramesh\_AR](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@Ramesh\_AR](https://forum.ansible.com/u/Ramesh_AR)\
**Post date:** [December 21, 2020, 7:04pm UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/1 "2020-12-21T19:04:29Z")

</div>

Hi Folks,

Does anyone had an experience to use imc\_rest module ? I’m trying to get information or output about hardware inventory . Say for example, I have equipmentPsu to check PSU status. however, the output is not showing when I run my playbook. is there a way to filter the attributes?

My playbook:

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 22, 2020, 5:15am UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/2 "2020-12-22T05:15:19Z")

</div>

I think you need to register the result of this module and then to some operation on it.  
Such as debug to display it.  
This is not specific to the imc\_rest module:

[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_variables.html#registering-variables](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#registering-variables)

---

<div class="post-metadata">

**Author:** ![Ramesh\_AR](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@Ramesh\_AR](https://forum.ansible.com/u/Ramesh_AR)\
**Post date:** [December 22, 2020, 9:23pm UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/3 "2020-12-22T21:23:19Z")

</div>

I already tried to set register and debug but got the below error.

“msg”: "Unsupported parameters for (imc\_rest) module: register Supported parameters include: content, hostname, password, path, protocol, timeout, username, validate\_certs

Thanks,  
Ramesh

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 23, 2020, 9:09am UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/4 "2020-12-23T09:09:35Z")

</div>

This is because your indentation is incorrect, so fix that.

---

<div class="post-metadata">

**Author:** ![Ramesh\_AR](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@Ramesh\_AR](https://forum.ansible.com/u/Ramesh_AR)\
**Post date:** [December 23, 2020, 8:32pm UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/5 "2020-12-23T20:32:51Z")

</div>

Yes, I’m able to get output now .thanks! … But that seems to be a very big and confusing ( what need to be looked )

anyone knows how to filter particular output from the below,

Playbook,

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 24, 2020, 6:59am UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/6 "2020-12-24T06:59:40Z")

</div>

That can be done with json\_query:  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_filters.html#selecting-json-data-json-queries](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#selecting-json-data-json-queries)

---

<div class="post-metadata">

**Author:** ![Ramesh\_AR](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@Ramesh\_AR](https://forum.ansible.com/u/Ramesh_AR)\
**Post date:** [December 24, 2020, 10:27pm UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/7 "2020-12-24T22:27:32Z")

</div>

I’m very new to json query though I tried to get specific output but couldn’t get it … it seems playbook runs good but no output.

Can someone help me to get json query pls .

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 27, 2020, 11:56am UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/8 "2020-12-27T11:56:43Z")

</div>

This will give you a list of just the values:

"{{ disk\_output|json\_query('configResolveDn.children[0].outConfig.children[0].equipmentPsu.attributes|[dn,  
id, operability, presence]') }}"

i.e.:

&nbsp;&nbsp;- sys/rack-unit-1/psu-1  
&nbsp;&nbsp;- '1'  
&nbsp;&nbsp;- operable  
&nbsp;&nbsp;- equipped

Something like this will yield a dict that contains keys as well:

"{{ disk\_output|json\_query('configResolveDn.children[0].outConfig.children[0].equipmentPsu.attributes.{dn:  
dn, id: id, operability: operability, presence:presence}') }}"

I.e.:

&nbsp;&nbsp;&nbsp;&nbsp;dn: sys/rack-unit-1/psu-1  
&nbsp;&nbsp;&nbsp;&nbsp;id: '1'  
&nbsp;&nbsp;&nbsp;&nbsp;operability: operable  
&nbsp;&nbsp;&nbsp;&nbsp;presence: equipped

---

<div class="post-metadata">

**Author:** ![Ramesh\_AR](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@Ramesh\_AR](https://forum.ansible.com/u/Ramesh_AR)\
**Post date:** [December 28, 2020, 8:02pm UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/9 "2020-12-28T20:02:47Z")

</div>

Thank you Dick Visser. I have added the json query in my playbook but It returned an error.

Can you please help me on this .

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 28, 2020, 10:02pm UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/10 "2020-12-28T22:02:12Z")

</div>

> Thank you Dick Visser. I have added the json query in my playbook but It returned an error.
> 
> Can you please help me on this .

> ++++++++++++++++++++++++++  
> &nbsp;&nbsp;register: result  
> - debug: msg="{{ result|json\_query(jmesquery) }}"  
> &nbsp;&nbsp;&nbsp;vars:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;jmesquery: "{{ result|json\_query('configResolveDn.children[0].outConfig.children[0].equipmentPsu.attributes.{dn: dn, id: id, operability: operability, presence: presence}') }}"  
> +++++++++++++++++++++++++++

You're mixing up things, by using a vars argument that includes the  
entire json\_query filter itself, and then doing json\_query on that,  
which fails.  
Either use a vars argument correctly, or don't use it at all.  
See the examples on  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_filters.html#selecting-json-data-json-queries](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#selecting-json-data-json-queries).  
I would only use a vars argument if the query contains variables  
itself, or lots of backticks etc.  
This case does not warrant that.

---

<div class="post-metadata">

**Author:** ![Ramesh\_AR](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@Ramesh\_AR](https://forum.ansible.com/u/Ramesh_AR)\
**Post date:** [December 28, 2020, 11:21pm UTC](https://forum.ansible.com/t/experts-help-need-for-imc-rest-module/34362/11 "2020-12-28T23:21:03Z")

</div>

Understood… Thanks. my bad it was very simple .

TASK [Display PSU status] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [host1] =\> {  
“msg”: {  
“dn”: “sys/rack-unit-1/psu-1”,  
“id”: “1”,  
“operability”: “operable”,  
“presence”: “equipped”  
}  
}
