#Debug msg specific output

1 messages · Page 1 of 1 (latest)

willow sandal
#

This is kind of 2 parts...
First, while using the collection netapp.ontap.na_ontap_rest_info and targeting the parameter volume_info, I have the results dumped to ontap_info. Then in the following task, I call debug and msg for "{{ ontap_info.ontap_info }}". This is fine but what I want to do is to target the name of the volume only in the output. how do I achieve this when the json output is this:
{
"ontap_info": {
"storage/volumes": {
"records": [
{
"uuid": "0311c2cc-bfa7-4c08-834d-6b5fd1353458",
"name": "labesxClus02_rmpOS_vnas02",
"_links": {
"self": {
"href": "/api/storage/volumes/0311c2cc-bfa7-4c08-834d-6b5fd1353458"
}
}
},

Second item, has anyone been able to get their AWX job output to be in yaml format instead of json...not a fan of json. I found the following but Im a little lost: https://forum.ansible.com/t/awx-human-readable-output-configuration-yaml/3016/14

Ansible

I don’t use AWX, but I believe you can just click on the result to see it in a more useful format. The default display is just intended to give you an overview, not show every piece of task information that is available.

soft island
#

You need a good understanding of dicts and lists in Ansible to use these structures correctly. Handling vars is the most frustrating thing in Ansible.

"records" contains a list of all the volumes returned to you.
{{ ontap_info.ontap_info['storage/volumes'].records }}

If you are sure there is only one record returned, you can grab the first element from the list and address the dictionary inside:
{{ ontap_info.ontap_info['storage/volumes'].records[0].name }}

There are two helpful options in the na_ontap_rest_info module:
use_python_keys: true changes the returned dict so it can be addressed with the dot notation:
{{ ontap_info.ontap_info.storage_volumes.records }}

hal_linking: false removes the _links part from the returned dict, so it is much easier to read. The link is only needed rarely from my experience.