Experts help need for imc_rest module

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:

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

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

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

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,

That can be done with json_query:
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#selecting-json-data-json-queries

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 .

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.:

  - sys/rack-unit-1/psu-1
  - '1'
  - operable
  - 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.:

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

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 .

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 .

++++++++++++++++++++++++++
  register: result
- debug: msg="{{ result|json_query(jmesquery) }}"
   vars:
     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.
I would only use a vars argument if the query contains variables
itself, or lots of backticks etc.
This case does not warrant that.

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”
}
}