How can I extract the version from the lengthy output of the module netapp.ontap.na_ontap_rest_info
?
This is my playbook and its output is quite lengthy
---
- hosts: localhost
collections:
- netapp.ontap
tasks:
- name: run ONTAP gather facts for cluster_node_info
netapp.ontap.na_ontap_rest_info:
hostname: "{{ lookup('env', 'ClusterName') }}"
username: "{{ lookup('env', 'ontap_admin_usr') }}"
password: "{{ lookup('env', 'ontap_admin_pwd') }}"
use_rest: always
https: true
validate_certs: false
gather_subset:
- cluster_node_info
fields:
- 'version'
From the example output below, I only need the first part of the version full, namely NetApp Release 9.12.1P4
ok: [localhost] => {
"changed": false,
"invocation": {
"module_args": {
"cert_filepath": null,
"feature_flags": null,
"fields": [
"version"
],
"force_ontap_version": null,
"gather_subset": [
"cluster_node_info"
],
"hostname": "clusterhostname",
"http_port": null,
"https": true,
"ignore_api_errors": null,
"key_filepath": null,
"max_records": 1024,
"ontapi": null,
"owning_resource": null,
"parameters": null,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"state": null,
"use_python_keys": false,
"use_rest": "always",
"username": "svc_ans-ontap",
"validate_certs": false
}
},
"ontap_info": {
"cluster/nodes": {
"_links": {
"self": {
"href": "/api/cluster/nodes?max_records=1024&fields=version"
}
},
"num_records": 2,
"records": [
{
"_links": {
"self": {
"href": "/api/cluster/nodes/578658e0-87fc-11e9-b8bd-00a098f2ea00"
}
},
"name": "node2",
"uuid": "578658e0-87fc-11e9-b8bd-00a098f2ea00",
"version": {
"full": "NetApp Release 9.12.1P4: Tue Jun 06 20:41:34 UTC 2023",
"generation": 9,
"major": 12,
"minor": 1
}
},
{
"_links": {
"self": {
"href": "/api/cluster/nodes/6aae0abe-a410-11e9-ae1d-00a098f2ea72"
}
},
"name": "node1",
"uuid": "6aae0abe-a410-11e9-ae1d-00a098f2ea72",
"version": {
"full": "NetApp Release 9.12.1P4: Tue Jun 06 20:41:34 UTC 2023",
"generation": 9,
"major": 12,
"minor": 1
}
}
]
}
}
}
What do I need to add to the playbook to process the version output to return only NetApp Release 9.12.1P4
?
TASK [debug] task path: /var/lib/jenkins/workspace/Infra-NetApp_ONTAP_Upgrade/NetApp_version.yml:21 ok: [localhost] => { "cluster_node_info.ontap_info['cluster/nodes'].records\n | map(attribute='version.full')\n | map('split', ':')\n | map(attribute=0)": "