I got this figured out.  I needed to add a step before, to create a list 
with all the values , then find the max of it.  

On Monday, August 26, 2019 at 12:42:47 PM UTC-5, Nicholas Britton wrote:
>
> Thank you, that has helped alot.   
>
> I was looking at the max option:
>
> - name: debug - show max lun number
>     debug:
>       msg: "{{item.lun.lun}}"
>     loop: "{{luns.json.data}}"
>     when: "{{item.lun.lun | max}}"
>
>
> But it returns the following:
> TASK [debug - show max lun number] 
> ****************************************************************************************************************************************
> fatal: [127.0.0.1]: FAILED! => {"msg": "The conditional check 
> '{{item.lun.lun | max}}' failed. The error was: Unexpected templating type 
> error occurred on ({{item.lun.lun | max}}): 'int' object is not 
> iterable\n\nThe error appears to be in 
> '/home/nbritton/ansible/gts-core-storage-operations/hds/get_luninfo.yml': 
> line 65, column 5, but may\nbe elsewhere in the file depending on the exact 
> syntax problem.\n\nThe offending line appears to be:\n\n\n  - name: debug - 
> show max lun number\n    ^ here\n"}
>
> The value i am after is the last one in the output here:
>
> TASK [debug new vars] 
> *****************************************************************************************************************************************************
> ok: [127.0.0.1] => {
>     "msg": "am1vmhost12,CL8-B,15,83,SFTP,6"
> }
>
>
>
>
> On Friday, August 23, 2019 at 3:22:58 PM UTC-5, Nicholas Britton wrote:
>>
>> I am trying to loop through a json object that is returned and list out 
>> key pieces of information, or later on do something with these key peices 
>> of information from each object.  I have been trying to do this with 
>> JMESpath examples but have not had much luck.   Would anyone be able to 
>> help point me in the right direction.    
>>
>> For this example i am trying to pull out hostGroup.hostGroupdId, 
>> hostGroup.hostgroupname, ldev.ldevid, lun.lun, lun.lunid
>>
>> Here is a sample of the output returned from json_out.json:
>>
>> TASK [debug lunpaths] 
>> *******************************************************************************************************************************************************************************
>> ok: [127.0.0.1] => {
>>     "msg": {
>>         "count": 4,
>>         "data": [
>>             {
>>                 "hostGroup": {
>>                     "hostGroupId": "CL7-A,15",
>>                     "hostGroupName": "host12",
>>                     "hostGroupNumber": 15,
>>                     "hostMode": "VMWARE_EX",
>>                     "hostModeOptions": [
>>                         54,
>>                         63
>>                     ],
>>                     "portId": "CL7-A",
>>                     "storageDeviceId": "886000999999"
>>                 },
>>                 "ldev": {
>>                     "attributes": [
>>                         "CVS",
>>                         "HDT"
>>                     ],
>>                     "blockCapacity": 2147483648,
>>                     "byteFormatCapacity": "1.00 T",
>>                     "clprId": 0,
>>                     "dataReductionMode": "disabled",
>>                     "dataReductionStatus": "DISABLED",
>>                     "emulationType": "OPEN-V-CVS",
>>                     "isDefined": true,
>>                     "isFullAllocationEnabled": false,
>>                     "isRelocationEnabled": true,
>>                     "label": "BackupSFTP",
>>                     "ldevId": 82,
>>                     "mpBladeId": 0,
>>                     "numOfUsedBlock": 3096576,
>>                     "poolId": 0,
>>                     "status": "NML",
>>                     "storageDeviceId": "886000999999",
>>                     "tierLevel": "all",
>>                     "tierLevelForNewPageAllocation": "M",
>>                     "usedCapacityPerTierLevel1": 1512,
>>                     "usedCapacityPerTierLevel2": 0
>>                 },
>>                 "lun": {
>>                     "lun": 5,
>>                     "lunId": "CL7-A,15,5",
>>                     "storageDeviceId": "886000428027"
>>                 }
>>             },
>>             {
>>                 "hostGroup": {
>>                     "hostGroupId": "CL7-B,15",
>>                     "hostGroupName": "host12",
>>                     "hostGroupNumber": 15,
>>                     "hostMode": "VMWARE_EX",
>>                     "hostModeOptions": [
>>                         54,
>>                         63
>>                     ],
>>                     "portId": "CL7-B",
>>                     "storageDeviceId": "886000999999"
>>                 },
>>                 "ldev": {
>>                     "attributes": [
>>                         "CVS",
>>                         "HDT"
>>                     ],
>>                     "blockCapacity": 2147483648,
>>                     "byteFormatCapacity": "1.00 T",
>>                     "clprId": 0,
>>                     "dataReductionMode": "disabled",
>>                     "dataReductionStatus": "DISABLED",
>>                     "emulationType": "OPEN-V-CVS",
>>                     "isDefined": true,
>>                     "isFullAllocationEnabled": false,
>>                     "isRelocationEnabled": true,
>>                     "label": "BackupSFTP",
>>                     "ldevId": 82,
>>                     "mpBladeId": 0,
>>                     "numOfUsedBlock": 3096576,
>>                     "poolId": 0,
>>                     "status": "NML",
>>                     "storageDeviceId": "886000999999",
>>                     "tierLevel": "all",
>>                     "tierLevelForNewPageAllocation": "M",
>>                     "usedCapacityPerTierLevel1": 1512,
>>                     "usedCapacityPerTierLevel2": 0
>>                 },
>>                 "lun": {
>>                     "lun": 5,
>>                     "lunId": "CL7-B,15,5",
>>                     "storageDeviceId": "886000428027"
>>                 }
>>             },
>>
>>
>>
>>
>>
>>
>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3df9e7e2-8635-4823-9211-470e309a428a%40googlegroups.com.

Reply via email to